docker containers logs clean

容器日志清理

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
posted @ 2020-11-18 21:37  mvpbang  阅读(250)  评论(0编辑  收藏  举报