docker 日志相关问题

不记录log:

docker run -it --log-driver none alpine ash

限制log文件的大小:

docker run --log-driver local --log-opt max-size=10m alpine echo hello world

具体支持的log类型参考这里

默认的log类型为local,详细参考这里

Option Description Example value
max-size The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (k, m, or g). Defaults to 20m. --log-opt max-size=10m
max-file The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. A positive integer. Defaults to 5. --log-opt max-file=3
compress Toggle compression of rotated log files. Enabled by default. --log-opt compress=false

Leave a Comment

Back to Top