clean containers logs
[root@k8s-master ~]# docker info |grep Root //docker rootdir
Docker Root Dir: /var/lib/docker
container logs:
/var/lib/docker/containers/container_id/xxxx.json.log
#list logs size
find /var/lib/docker/containers/ -name *-json.log |xargs du -sh
#reset log
cat /dev/null >/var/lib/docker/containers/xxxx/xxxx.log-json.log
docker log-driver
/etc/docker/daemon.json
{
"registry-mirrors": [
"http://f613ce8f.m.daocloud.io"
],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m",
"max-file": "3"
}
}
systemctl daemon-reload && systemctl restart docker
注意这个修改只对新容器生效,老容器不生效
rancher-set loglevel
docker exec -ti <container_id> loglevel --set trace/debug/info/error
docker logs-driver
--log-driver=json-file //default /var/lib/docker/containers/xxxx/xxx.log
json-file
syslog
journald
gelf
fluentd
none //关闭日志记录
logrotate
/etc/logrotate.d/docker
/var/lib/docker/containers/*/*.log {
daily
rotate 3
compress
delaycompress
missingok
copytruncate
}
标签:容器,滚动,log,lib,json,var,日志,docker,containers
From: https://www.cnblogs.com/xiaochina/p/17471548.html