杀死所有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'
网友评论