清理docker的/var/lib/docker
服务器磁盘太小了,部署的商业xary只能在/目录下,不想扩容,不想做链接
sec-vulnscan-host1.idc2. 2021-04-25 15:05:19 磁盘:/ 剩余空间不足20% 17.9097%
查看占用大小:
[root@sec-vulnscan-host1 ~]# du -hs /var/lib/docker/ 217G /var/lib/docker/
docker system df命令,类似于Linux上的df命令,用于查看Docker的磁盘使用情况
[root@sec-vulnscan-host1 /]# docker system df TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 24 12 22.68GB 3.952GB (17%) Containers 21 13 8.077GB 7.455GB (92%) Local Volumes 17 6 67.99MB 67.99MB (99%) Build Cache 0 0 0B 0B
docker system prune命令可以用于清理磁盘,删除关闭的容器、无用的数据卷和网络,以及dangling镜像
[root@sec-vulnscan-host1 /]# docker system prune WARNING! This will remove: - all stopped containers - all networks not used by at least one container - all dangling images - all build cache Are you sure you want to continue? [y/N] y Deleted Containers: 03700adb598d50d4076583319e6210c6c59b0e3b4b379bc5882098f401b140a9 cff2f748cf1a57832ed9c4ed7f8a5e52976784727ca9faaa2f0779ba9da82d9f 0f8e22a270a1a0066919e76870c3f3d8052f125b15f0d7f563ba40301a1f5ca4 cd13c111761c7dc41d36d91d77246965c54d44ca35f57b0347aa476499be2622 d7a06a30cf5587c6880b60f9da624ebc4dfa908042298776f798b8e06fe4bd5a a9d43babf9c9a9dc3a48d91035e4278cae31c866ba0299c7aab33128d1389adc 722ec76f3a237ccc68582072ab0088a44915f2b4395942961559f74460f656ad 1a2937b50a3f60fd8e52a5e8450484886b2b2fd377744929395def1e78734036 Total reclaimed space: 7.455GB
清理前:
[root@sec-vulnscan-host1 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 300G 247G 54G 83% / devtmpfs 7.8G 0 7.8G 0% /dev tmpfs 7.8G 12K 7.8G 1% /dev/shm tmpfs 7.8G 772M 7.1G 10% /run tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup /dev/sdb 296G 20G 261G 8% /home shm 64M 0 64M 0% /var/lib/docker/containers/05e906e9cdaff232734d3abd07bf4a8e294ed62c13f0aa204a80a56f251e9eeb/mounts/shm shm 64M 124K 64M 1% /var/lib/docker/containers/e811306c2d4122f02bcf04223542583029f2edcaefd608d713344d9913fcc5d7/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/4c00adbcb54b44cd88228d11eaa689bd2a5670090cd37b0874c3b7670479ed48/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/f6eddc69803a499eaa20b95835faa97ac457d9d238e7177d26acfeef03a6dd61/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/7eefacc651f357b4e7ff9760c365a14034620346adea215a854d8f2953bad01e/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/bcfe0c17af42222efa1276dde62143ac426ae1fca1336819d828c6b14e083e5b/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/fcae2974daa4784ffc34033852961768c201a6d7edc96c95cf5b7977dde2e01a/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/f530a773618dd8c9e49834ca57176f8809a2c93b4b710f66f34fd52033ab14f9/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/ecd55ef06a569004e01188f23b1d9bee727cc7a2ab918620acac47bcbe1ae8a0/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/cab200c9185e85f4fa0a7efd8de70dd93fb66e7a0e9736bb79729c358b3704a9/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/b23efca9e970b08d8bb88e291c99b1dbcce625cb87e8573aff8fd4443054c98f/mounts/shm tmpfs 1.6G 0 1.6G 0% /run/user/0 shm 64M 0 64M 0% /var/lib/docker/containers/fe3534975ff61e04818bd0f7d7f3ce0ac971381931ae272832ff1c4d26f7a5bc/mounts/shm shm 64M 4.0K 64M 1% /var/lib/docker/containers/292954665ce48e65a499198ee3d7d057c59342114e077e8de510263956b283d7/mounts/shm
清理后:
[root@sec-vulnscan-host1 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 300G 157G 144G 53% / devtmpfs 7.8G 0 7.8G 0% /dev tmpfs 7.8G 12K 7.8G 1% /dev/shm tmpfs 7.8G 804M 7.0G 11% /run tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup /dev/sdb 296G 20G 261G 8% /home shm 64M 0 64M 0% /var/lib/docker/containers/05e906e9cdaff232734d3abd07bf4a8e294ed62c13f0aa204a80a56f251e9eeb/mounts/shm shm 64M 124K 64M 1% /var/lib/docker/containers/e811306c2d4122f02bcf04223542583029f2edcaefd608d713344d9913fcc5d7/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/4c00adbcb54b44cd88228d11eaa689bd2a5670090cd37b0874c3b7670479ed48/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/f6eddc69803a499eaa20b95835faa97ac457d9d238e7177d26acfeef03a6dd61/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/7eefacc651f357b4e7ff9760c365a14034620346adea215a854d8f2953bad01e/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/bcfe0c17af42222efa1276dde62143ac426ae1fca1336819d828c6b14e083e5b/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/fcae2974daa4784ffc34033852961768c201a6d7edc96c95cf5b7977dde2e01a/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/f530a773618dd8c9e49834ca57176f8809a2c93b4b710f66f34fd52033ab14f9/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/ecd55ef06a569004e01188f23b1d9bee727cc7a2ab918620acac47bcbe1ae8a0/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/cab200c9185e85f4fa0a7efd8de70dd93fb66e7a0e9736bb79729c358b3704a9/mounts/shm shm 64M 0 64M 0% /var/lib/docker/containers/b23efca9e970b08d8bb88e291c99b1dbcce625cb87e8573aff8fd4443054c98f/mounts/shm tmpfs 1.6G 0 1.6G 0% /run/user/0 shm 64M 0 64M 0% /var/lib/docker/containers/fe3534975ff61e04818bd0f7d7f3ce0ac971381931ae272832ff1c4d26f7a5bc/mounts/shm shm 64M 4.0K 64M 1% /var/lib/docker/containers/292954665ce48e65a499198ee3d7d057c59342114e077e8de510263956b283d7/mounts/shm
【版权所有@Sevck 博客地址http://www.cnblogs.com/sevck】 可以转载,注明出处.