docker日志文件过大

发现服务器磁盘空间不足,其中有很多/var/lib/docker/overlay2/..

# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.8G     0  3.8G   0% /dev
tmpfs           770M  1.3M  769M   1% /run
/dev/vda1        59G   55G  2.0G  97% /
tmpfs           3.8G     0  3.8G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.8G     0  3.8G   0% /sys/fs/cgroup
tmpfs           770M     0  770M   0% /run/user/0
overlay          59G   55G  2.0G  97% /var/lib/docker/overlay2/6b555603eb9808afba38ff0e7785e1a88d912009b203b2fc81f58306ed89ce38/merged
overlay          59G   55G  2.0G  97% /var/lib/docker/overlay2/a5f8bc2e5f4cc7c26361f435e84534237397e86c1119a26d9b46fdca7d36e1eb/merged
overlay          59G   55G  2.0G  97% /var/lib/docker/overlay2/36f372192a4e716b83c59259d65813f94e469b2f3e3ecc9fefed72bc59b7d5d0/merged
overlay          59G   55G  2.0G  97% /var/lib/docker/overlay2/a70f1dfe08cb468b21529d08c0883acd6fdb5bf4830d49d5306d45cfdef29f63/merged
overlay          59G   55G  2.0G  97% /var/lib/docker/overlay2/4fa90b464fb5f403a0d6019b37b3130fecb3c01222e2e7e6caa2eaff534006d7/merged
overlay          59G   55G  2.0G  97% /var/lib/docker/overlay2/2013007d3af2694a5ad034d41ecedad5a22b286390f5af75666ae7454437f782/merged
overlay          59G   55G  2.0G  97% /var/lib/docker/overlay2/2e030df028cf8d55f6ae1718f7631cd4ced0d1b22fe14da8d07bc5baa0b5847f/merged
overlay          59G   55G  2.0G  97% /var/lib/docker/overlay2/dcbc5f34c9114e23e12d01a69ea473d002e6bab878c4db586552fc7a4f01e388/merged

docker容器所在的目录是/var/lib/docker

cd /var/lib/docker
# 这个命令是查看当前目录下所有子目录及文件的大小,找占用空间大的cd进去再看是哪个文件
du -h --max-depth=1

一般都是某个docker的日志太大,直接删除

cd /var/lib/docker/containers/73a43a0598240d0fe9671d8c350b60d4eb273c39ee010bdaf1dd474b3b8a3b20
rm -rf *.log

删除完了以后重启一下docker服务

sudo systemctl daemon-reload
sudo systemctl restart docker

posted on 2023-06-17 11:34  Netsharp  阅读(106)  评论(0编辑  收藏  举报

导航