查看日志大小:在linux系统中 创建docker_logs.sh文件,输入 sh docker_logs.sh 命令查看日志文件大小
/var/lib/docker/containers为docker默认日志输出路径
echo "======== docker containers logs file size ========"
logs=$(find /var/lib/docker/containers/ -name *-json.log)
for log in $logs
do
ls -lh $log
done
清空日志文件:创建clear_docker_logs.sh文件,输入 sh clear_docker_logs.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 ========"