参考:https://blog.youkuaiyun.com/weixin_32820767/article/details/81196250
0 du -hs /var/lib/docker/ 命令查看磁盘使用情况。
sudo du -hs /var/lib/docker/
1 docker system df命令,类似于Linux上的df命令,用于查看Docker的磁盘使用情况:
[root@k8s-master1 ~]# docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 24 8 3.008GB 2.292GB (76%)
Containers 17 16 2.294kB 0B (0%)
Local Volumes 2 0 0B 0B
Build Cache 0 0 0B 0B
2 docker system prune命令可以用于清理磁盘,删除关闭的容器、无用的数据卷和网络,以及dangling镜像(即无tag的镜像)
# 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]
Total reclaimed space: 38.07GB
3 docker system prune -a命令清理得更加彻底,可以将没有容器使用Docker镜像都删掉。注意,这两个命令会把你暂时关闭的容器,以及暂时没有用到的Docker镜像都删掉了…所以使用之前一定要想清楚.。我没用过,因为会清理 没有开启的 Docker 镜像。