我的容器名字是docker_tomcat
docker inspect --format='{{.LogPath}}' docker_tomcat
输出为: /var/lib/docker/containers/15b628ef821b5735faca40ef3ed9eaf89eee9517f1a62c5410ed40cb33f3e80f/15b628ef821b5735faca40ef3ed9eaf89eee9517f1a62c5410ed40cb33f3e80f-json.log
然后处理它就行了。
脚本如下:
#!/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 =========================="
|