查看tag为none的镜像
docker images -f "dangling=true"
删除tag为none的镜像
docker rmi $(docker images -f "dangling=true" -q)
查看docker占用的磁盘空间
[root@node1 ~]# docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 35 3 5.039GB 4.603GB (91%)
Containers 3 2 19.69kB 19.5kB (99%)
Local Volumes 28 0 3.782MB 3.782MB (100%)
Build Cache 0 0 0B 0B
查找所有无用的volume
docker volume ls -qf dangling=true
删除所有无用的volume
docker volume rm $(docker volume ls -qf dangling=true)
查看所有docker文件夹
find / -name docker
可以使用
df
或者du
命令查看文件夹具体使用情况,参考Linux系统磁盘使用情况相关命令.
如:du -hs /var/lib/docker/
查找所有未运行的容器
docker ps -a|grep Exited
docker ps -qf status=exited
删除所有未运行的容器
docker rm $(docker ps -a|grep Exited |awk '{print $1}')
prune命令
- 删除所有无用的容器
docker container prune
- 删除所有无用的镜像
docker image prune
- 删除所有无用的volume
docker volume prune
- 删除所有无用的network
docker network prune
- 删除docker系统中所有无用的,包括容器、镜像、volume、网络等
docker system prune
注意
docker system prune
和docker system prune -a
两者的区别:
[root@node1 ~]#
docker system prune
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
- all dangling build cache
Are you sure you want to continue? [y/N]
[root@node1 ~]#
docker system prune -a
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all images without at least one container associated to them
- all build cache
Are you sure you want to continue? [y/N]