实践:
docker system prune -a -f
[root@image docker]# du --max-depth=1 -h
4.0K ./swarm
4.0K ./containers
4.0K ./trust
138M ./image
16K ./plugins
4.0K ./tmp
51M ./volumes
74G ./overlay2
96K ./network
19M ./buildkit
4.0K ./runtimes
74G .
[root@image overlay2]# 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
Deleted Networks:
app_server_default
app_server_net
Deleted build cache objects:
m9hwyz8mxrgdvy5zf63wyp3hk
xtriwkjukr23ty1ezr1oaze18
s62yt89ogy9znluwpnpye1lo1
uphyc3tj092n0jzawh5tedow0
Total reclaimed space: 71.14GB
[root@image overlay2]#
[root@image docker]# du --max-depth=1 -h
4.0K ./swarm
4.0K ./containers
4.0K ./trust
5.5M ./image
16K ./plugins
4.0K ./tmp
51M ./volumes
1.9G ./overlay2
96K ./network
15M ./buildkit
4.0K ./runtimes
2.0G .
[root@image ~]# 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: pycharm_helpers:PY-212.5457.59
deleted: sha256:13ac5d714d7a4a6e9147b79bd7329fd347ab3ab68aeb434c4901bc81bd8512a7
deleted: sha256:ab120f4f4c10a417688b2702361a5c0fa5831e0c66fbd0e7945903e1adee6b6b
deleted: sha256:af75f0c3583b895c0230aaafbef08ecf36f532ce69bfde2b3624e31b447253ab
deleted: sha256:1db4f28ea508c4accd41eee3335ef78809253704a2b043f52ef3432c47c8a515
deleted: sha256:94ccd6950c4a742630fdec79fcf403cdcdc7bc722e257d10300d4f3860871541
deleted: sha256:ba8309e5b8fb6d8922bcceb3deef06cc48e2b5f158a83f4bc062ac9f6d372e27
deleted: sha256:e3da60b1544be1bd776e3a0f3a0cfccaa366ebd032875729e0cece6f104336c3
deleted: sha256:d4cc2df3cc31505428ae1b293a4d9ecb5aad0422c16b8b432bbf7000559b919e
untagged: busybox:latest
untagged: busybox@sha256:2376a0c12759aa1214ba83e771ff252c7b1663216b192fbe5e0fb364e952f85c
deleted: sha256:5242710cbd55829f6c44b34ff249913bb7cee748889e7e6925285a29f126aa78
deleted: sha256:feb4513d4fb7052bcff38021fc9ef82fd409f4e016f3dff5c20ff5645cde4c02
untagged: python:3.7
untagged: python@sha256:d98fd1fa8fd1756bfe883b5004a60cfc428a1ce6e575652b771b66c8db222478
untagged: app_draw_img:latest
deleted: sha256:00bc8a93673b54a3f514a562f7fa5b83128d704890299ecad785382e6d131bf8
deleted: sha256:4ae735137e0a0516cb987597b05df60e51c3ba0525438821ec2de0a4b07ab97a
deleted: sha256:17c650cf4cf322a52a8da82147b10b0c1cdc51fc1564f745b26c1585dc44d655
deleted: sha256:43aaf4b3afc1d7a3d1411bfdc9f4a4bfdcc79491c7eb10e73b461ba1d3d8d172
deleted: sha256:84e510249c0dc113d43332faf27c5a349c92255fa3f16ead64cccd63128b3ee3
deleted: sha256:7dfdbe99a6aea1bed43ac1c858a2f6c5803d1757ade15ca42e05450562ed9fcd
deleted: sha256:9eac2adccae43218def0d73e5965a6fa93860ae4b1e8456e085eb0988064a31c
deleted: sha256:1d9f01a53decad0faf32e3dc6518b12b9d5e15fbf50e03717579fccc3f39475b
deleted: sha256:35cfbba5d5e2c1fd6273f03a2e296a34bd771eb6417956b14e220b4adf8d5843
deleted: sha256:648f686a81c3f8a99a3491f392c52de6eae4de71ccd6086c4c686834e0e4ef26
deleted: sha256:1c3ba326dcd0a1bbdf5ac3dba5e0a87e0865e7a2bf30968fe1b04ca9aa574779
Total reclaimed space: 943.9MB
[root@image ~]# docker system prune -a -f
Total reclaimed space: 0B
[root@image ~]#
overlay2占用磁盘空间过大,磁盘太小,清理下工作空间就好了。
当我清理了下workspace,发现还是没有多少地方空余出来。然后就开始一个一个检查
df -h
查看磁盘占用
du -sh *
查看当前目录下的文件占用情况
结果发现了/var/lib/docker/overlay 占满了
网上查一下这个目录的作用,说是 overlay/overlay2表示Docker的存储驱动,可以参考一下这篇文章:https://docs.docker.com/storage/storagedriver/overlayfs-driver/ 看了下之后,才想起容器/镜像等都会存在这个目录下,当量大的时候就会占满硬盘。而jenkins打包的话。。。。打包一次会生成一个images。 一直没做个计划清理一下镜像。。小秦出来背锅。。。。 开始清理images,使用下个命令docker system prune
该指令是自动清理空间
该指令默认会清除所有如下资源:
已停止的容器(container)
未被任何容器所使用的卷(volume)
未被任何容器所关联的网络(network)
所有悬空镜像(image)
注意:
该指令默认只会清除悬空镜像,未被使用的镜像不会被删除。
添加 -a 或 --all 参数后,可以一并清除所有未使用的镜像和悬空镜像。
可以添加 -f 或 --force 参数用以忽略相关告警确认信息。
指令结尾处会显示总计清理释放的空间大小。
可以看下docker的占用情况,使用下面命令
docker system df
可以查询镜像(Images)、容器(Containers)和本地卷(Local Volumes)等空间使用大户的空间占用情况
root@serverc04:~# docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 14 2 1.281GB 1.182GB (92%)
Containers 2 2 94.1MB 0B (0%)
Local Volumes 4 0 373.7MB 373.7MB (100%)
Build Cache 0 0 0B 0B
root@serverc04:~#
docker问题:overlay2占用磁盘空间过大 - Fugui - 博客园 https://www.cnblogs.com/yifugui/p/14692507.html
翻译
搜索
复制
标签:image,system,磁盘空间,docker,sha256,root,overlay2 From: https://www.cnblogs.com/papering/p/17848273.html