docker容器日志过多,导致磁盘空间耗尽。从而rancher server无法启动。记录关键命令。
查看容器相关信息:
docker inspect 容器id
查看磁盘占用大小信息:
df -h
查看目录占用总大小:
du -hs 目录
列举容器日志大小:
ls -lh $(find /var/lib/docker/containers/ -name *-json.log)
清除日志脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
echo "==================== start clean docker containers logs =========================="
logs=$(find /var/lib/docker/containers/ -name *-json.log)
for log in $logs
do
echo "clean logs : $log"
cat /dev/null > $log
done
echo "==================== end clean docker containers logs =========================="查看容器日志脚本
1
2
3
4
5
6
7
8
9
echo "======== docker containers logs file size ========"
logs=$(find /var/lib/docker/containers/ -name *-json.log)
for log in $logs
do
ls -lh $log
done