docker log cleaning

First make sure the storage engine used docker

docker info

If you are using Logging Driver: json-file, then the default log in /var/lib/docker/contains/xxxxx/xxxxx-json.log

#!/bin/sh 

logs=`find /var/lib/docker/containers/ -name *-json.log`  

for logfile in $logs  
do  
echo " "  > $logfile 
done  

Then put in crontable. Position engine change log
cat /etc/docker/daemon.json

{
  "log-driver": "json-file",
  "log-opts": {"max-size": "10m", "max-file": "3"}
}

 

If you are using Logging Driver:  journald 日志清理

View journal space

journalctl --disk-usage

 

Setting the maximum system journal 10M, and manually empty

vim /etc/systemd/journald.conf

SystemMaxUse=5M
RuntimeMaxUse=1M
journalctl --vacuum-size=1M
systemd restart systemctl - journald.service
 
# View using size
journalctl --disk-usage

 

The systemd log is written to disk:

1. Create a log store directory, and add permissions systemd-journal in / var / log / directory:

mkdir /var/log/journal
chown root:systemd-journal /var/log/journal
chmod 755 /var/log/journal

 

 

 

2. Sending a USR1 to systemd-journald, or restart:

killall -USR1 systemd-journald

 

Guess you like

Origin www.cnblogs.com/fengjian2016/p/12376831.html
Recommended