1.容器日志一般存放在/var/lib/docker下面,可使用如下命令查看各个日志的文件大小
ls -lh $(find /var/lib/docker/containers/ -name *-json.log)
2.清理脚本rmdockerlog.sh
#!/bin/sh 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 =========================="
3.运行清理脚本
/bin/sh rmdockerlog.sh