手动清理
cat /dev/null > *-json.log
启动时添加配置
docker run --log-driver=json-file --log-opt max-size=10m my-container
脚本
#!/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 =========================="