删除一个或多个container
删除一个container
查看container ID:1
docker ps -a
删除:1
docker rm container_name/ID
使用name或者id删除。
删除多个container
同时运行了hello-world两次,若要一次性删除hello-world的container,使用命令查看:1
2
3docker ps –a –f ancestor=hello-world
或
docker ps –s –filter=”ancestor=hello-world”
删除这两个:1
docker rm $( docker ps -a -f ancestor=hello-world )
所以,删除所有的container,命令格式1
docker rm $( docker ps -a -q )
删除一个或多个image
删除image前需要stop 所有的container1
docker stop $(docker ps -a -q)
查看所有的image1
docker images
删除一个 hello-world image ,命令格式:1
docker rmi image_name/ID
例如:1
docker rmi c54a2cc56
若要删除所有的image, 使用命令:1
docker rmi $(docker images -q)
有时image删不掉,可以强制删除:1
2
3docker rmi imagename
或
docker rmi -f imagename