使用logrotate日志分割,

针对containers的分割

vi /etc/logrotate.d/docker-containers

/var/lib/docker/containers/*/*.log {
    daily
    rotate 7
    copytruncate
    missingok
    compress
    delaycompress
    maxsize 10G
    minsize 1024k
}
wq!

针对volumes的分割

vi /etc/logrotate.d/docker-volumes

/var/lib/docker/volumes/*/_data/*.log {
    daily
    rotate 7
    copytruncate
    missingok
    compress
    delaycompress
    maxsize 10G
    minsize 1024k
}
wq!


可以运行以下命令看看是否有效

logrotate -f /etc/logrotate.conf