docker-compose.yaml
logging:options:max-size: "10m"
docker run
docker run -d \--name example-container \--log-opt max-size=10m \--log-opt max-file=3 \nginx:latest
docker daemon全局配置
/etc/docker/daemon.json
参考文档:https://docs.docker.com/config/containers/logging/configure/
{"log-driver": "json-file","log-opts": {"max-size": "10m","max-file": "3"}
}