杀死所有running状态的容器
docker kill $(docker ps -q)
删除所有已经停止的容器
docker rm $(docker ps -a -q)
删除所有\’untagged/dangling\’ ()状态的镜像
docker rmi $(docker images -q -f dangling=true)
删除所有镜像:
docker rmi $(docker images -q)
为这些命令创建别名:
# ~/.bash_aliases # Kill all running containers. alias dockerkillall='docker kill $(docker ps -q)' # Delete all stopped containers. alias dockercleanc='printf "\n>>> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q)' # Delete all untagged images. alias dockercleani='printf "\n>>> Deleting untagged images\n\n" && docker rmi $(docker images -q -f dangling=true)' # Delete all stopped containers and untagged images. alias dockerclean='dockercleanc || true && dockercleani'
参考资料:
https://www.calazan.com/docker-cleanup-commands/
原创文章,转载请注明:转载自Web开发笔记 | Docker清除容器镜像命令
本文链接地址:https://www.magentonotes.com/docker-rm-container-commands.html
Comments on this entry are closed.