- 查看磁盘使用情况
[root]# du -hs /var/lib/docker/
17G /var/lib/docker/
[root]#
- 查看Docker的磁盘使用情况
[root]# docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 28 9 8.331GB 5.028GB (60%)
Containers 9 9 388.4MB 0B (0%)
Local Volumes 27 1 121kB 114.2kB (94%)
Build Cache 0 0 0B 0B
[root]#
- 清理磁盘,删除关闭的容器、无用的数据卷和网络,以及dangling镜像(即无tag的镜像)
[root]# 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] y
Total reclaimed space: 0B
- 清理得更加彻底
可以将没有容器使用Docker镜像都删掉。注意,这两个命令会把你暂时关闭的容器,以及暂时没有用到的Docker镜像都删掉了…所以使用之前一定要想清楚.。我没用过,因为会清理 没有开启的 Docker 镜像
[root]# 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] y
Deleted Images:
untagged: centos:7.2.1511
untagged: centos@sha256:50cca1e74da4b6a4eb4ade029c8fdd4ee8564776801914d9bd89df8c6344add0
Total reclaimed space: 4.42GB