删除所有未运行 Docker 容器
docker rm $(docker ps -a -q)
删除所有 Docker 镜像
删除所有未打 tag 的镜像
docker rmi $(docker images -q | awk '/^<none>/ { print $3 }')
删除所有镜像
docker rmi $(docker images -q)
根据格式删除所有镜像
docker rm $(docker ps -qf status=exited)
实际示例:
[root@master01 ~]# docker rmi $(docker images -q) Deleted: sha256:51482802dfa3c539a9fb6eb94d9707a2beb37060660dc85024f34cdb1e3270f1 Deleted: sha256:b202d6356beee8daa08cc0eb1f2c600e0f8a925d6123ed4dafd7181eea5be7b2 Deleted: sha256:690ab1b03b8fd1b753bf99c05f9d0eb35b31c2cd1b0933c6ca920340afba1510 Deleted: sha256:7b198487618230e657b6105678da7bf4ae841543a0e6baa8badced883a3e967b Untagged: cargo.caicloudprivatetest.com/zhiyi-system-test_devops/fashionbi-tomcat-test:latest Untagged: cargo.caicloudprivatetest.com/zhiyi-system-test_devops/fashionbi-tomcat-test@sha256:133ccff132298a87ed264065bd4a7f2f77f7aca4e98a3279b4602a866c1b173c Deleted: sha256:c667469af1f4b230cb433daab1f6725c341da1c85fd33240cf1cf2c51a93e86 [root@master01 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 17G 11G 6.7G 61% /