The blog about containerisation, virtual machines and useful shell snippets and findings

Docker logrotate

Actually you don’t need any logrotate for docker, as it has built-in.

Just set to this /etc/docekr/daemon.json

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3" 
  }
}


max-size No -1 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 -1 (unlimited). This is used by json-log required to keep the docker log command working.
max-file No 1 The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. Only effective when max-size is also set. A positive integer. Defaults to 1.