/var/lib/docker/overlay2/*/merged占用太多空间



问题描述:

在我的系统中,/var/lib/docker/overlay2/*/merged占用了太多的空间,详细信息如下:

root@sriov-TaiShan-200:~# df -h --total
Filesystem          Size  Used Avail Use% Mounted on
udev                 63G     0   63G   0% /dev
tmpfs                13G  6.2M   13G   1% /run
/dev/nvme0n1p2      2.9T  2.4T  329G  89% /
tmpfs                63G     0   63G   0% /dev/shm
tmpfs               5.0M     0  5.0M   0% /run/lock
tmpfs                63G     0   63G   0% /sys/fs/cgroup
/dev/loop0          128K  128K     0 100% /snap/bare/5
/dev/loop1           49M   49M     0 100% /snap/core18/2406
/dev/loop2           49M   49M     0 100% /snap/core18/2349
/dev/loop3           58M   58M     0 100% /snap/core20/1437
/dev/loop5          229M  229M     0 100% /snap/gnome-3-38-2004/100
/dev/loop6           73M   73M     0 100% /snap/lxd/23043
/dev/loop7          198M  198M     0 100% /snap/gnome-3-34-1804/73
/dev/nvme0n1p1      512M  5.2M  507M   1% /boot/efi
/dev/loop8           66M   66M     0 100% /snap/gtk-common-themes/1519
/dev/loop9           49M   49M     0 100% /snap/snap-store/545
/dev/loop10         229M  229M     0 100% /snap/gnome-3-38-2004/88
/dev/loop11          39M   39M     0 100% /snap/snapd/15541
/dev/loop14         198M  198M     0 100% /snap/gnome-3-34-1804/75
/dev/loop15          73M   73M     0 100% /snap/lxd/23003
/dev/loop16          53M   53M     0 100% /snap/snap-store/559
//10.67.93.97/work  916G  816G  100G  90% /mnt
/dev/loop17          82M   82M     0 100% /snap/gtk-common-themes/1534
/dev/loop13          39M   39M     0 100% /snap/snapd/15909
/dev/loop12          58M   58M     0 100% /snap/core20/1498
tmpfs                13G   16K   13G   1% /run/user/0
tmpfs               126G   12K  126G   1% /var/lib/kubelet/pods/12baa83c-6696-43f3-b060-85ba620867aa/volumes/kubernetes.io~projected/kube-api-access-j26q8
overlay             2.9T  2.4T  329G  89% /var/lib/docker/overlay2/150f4adf713b9882cd39e5580204040f20dcebf20205c9c62b55a85ac416da89/merged
shm                  64M     0   64M   0% /var/lib/docker/containers/9b02ed0d68aa3c24531b1e2852861a202b36b9d7d08645ee170035a3eab48747/mounts/shm
overlay             2.9T  2.4T  329G  89% /var/lib/docker/overlay2/803a832d1a228c7e57b47b9d53244deadc98dbe41248a478d3b6981bc111832d/merged
total               9.9T  8.0T  1.4T  86% -
root@sriov-TaiShan-200:~# docker system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          2         2         109.7MB   0B (0%)
Containers      2         2         2.294kB   0B (0%)
Local Volumes   0         0         0B        0B
Build Cache     0         0         0B        0B
root@sriov-TaiShan-200:~# du -h --max-depth=1 /var/lib/docker/overlay2 | sort -rh | head -25
223M    /var/lib/docker/overlay2
111M    /var/lib/docker/overlay2/803a832d1a228c7e57b47b9d53244deadc98dbe41248a478d3b6981bc111832d
68M /var/lib/docker/overlay2/6b7c00ae09c4df6f35e65114513bd6216c2436e62ae26c3b91b4c2ab60734662
42M /var/lib/docker/overlay2/94b81b09cc4a7ca3ead72888264e3cff25af77d2fc00334847aa2c3bde225e8a
1.6M    /var/lib/docker/overlay2/65ca885064b7df65728ea2864d3f633f035d4b9f3348ae4bcdc8c926157b9552
528K    /var/lib/docker/overlay2/150f4adf713b9882cd39e5580204040f20dcebf20205c9c62b55a85ac416da89
488K    /var/lib/docker/overlay2/5e344fbdc03c21013a38b1a82987d7e9094b5d13fe96d0f89f6e31a096f51c9c
48K /var/lib/docker/overlay2/150f4adf713b9882cd39e5580204040f20dcebf20205c9c62b55a85ac416da89-init
36K /var/lib/docker/overlay2/l
32K /var/lib/docker/overlay2/803a832d1a228c7e57b47b9d53244deadc98dbe41248a478d3b6981bc111832d-init

我尝试过的事情:

  1. 扩展lv/dev/ubuntu-vg/ubuntu-lv大小,但没有运气
  2. 用下面的步骤重新安装docker,但没有运气
apt-get purge docker-ce
rm -rf /var/lib/docker
rm -rf /etc/docker
apt-get remove docker docker-engine docker.io containerd runc
/etc/apt/sources.list.d/docker.list > /dev/null
apt update
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
apt update
apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
  1. docker system prune -a but no luck
root@sriov-TaiShan-200:~# 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
Total reclaimed space: 0B

更新docker似乎没有使用那么多磁盘空间。通过du的结果,是其他东西占据了空间。但是overlay 2.9T 2.4T 329G 89%/var/lib/docker/overlay2/803a832d1a228c7e57b47b9d53244deadc98dbe41248a478d3b6981bc111832d/merged是相当混乱的。

root@sriov-TaiShan-200:# du -h --max-depth=1 / --exclude=mnt --exclude=proc --exclude=home | sort -rh
2.3T    /
1.6T    /var
686G    /root
15G /usr
6.1G    /snap
3.6G    /x86_64-linux-gnu
1.2G    /boot
88M /opt
16M /etc
6.2M    /run
92K /tmp
16K /lost+found
12K /media
4.0K    /srv
4.0K    /cdrom
0   /sys
0   /dev

合并的文件夹是覆盖的文件系统,它们本身不占用磁盘空间,相反df报告底层文件系统的磁盘使用情况,在您的示例中是/:

/dev/nvme0n1p2      2.9T  2.4T  329G  89% /
overlay             2.9T  2.4T  329G  89% /var/lib/docker/overlay2/150f4adf713b9882cd39e5580204040f20dcebf20205c9c62b55a85ac416da89/merged
overlay             2.9T  2.4T  329G  89% /var/lib/docker/overlay2/803a832d1a228c7e57b47b9d53244deadc98dbe41248a478d3b6981bc111832d/merged

磁盘使用情况可以在根文件系统上的任何位置,因此您需要检查整个驱动器以查找正在使用的磁盘空间。这可能与docker无关。


  1. 扩展lv/dev/ubuntu-vg/ubuntu-lv大小,但没有运气

您的根文件系统被列为/dev/nvme0n1p2,所以我不确定更改lv会如何影响它。


对于容器,通常使用磁盘的地方是:

<<ol>
  • 图像层/gh>
  • 容器RW文件系统(从应用程序写入到容器文件系统)
  • 集装箱输出日志
  • docker的快速清理是docker system prune。还有更多的选择,以及在这个答案中描述的修剪中没有包含的东西。

    相关内容

    • 没有找到相关文章