version: "3"
services:
    logging:
          driver: json-file
          options:
            max-size: "200m" # 单个文件大小为200m 200k 2g
            max-file: "10" # 最多10个文件
  • /etc/docker/daemon.json
{
    "log-driver":"json-file",
    "log-opts": {"max-size":"20m", "max-file":"4"}
}


重启服务生效配置
sudo systemctl daemon-reload
sudo systemctl restart docker

日志文件位置

/var/lib/docker/containers/