I am running into a little problem with my Docker logs on a critical piece of infrastructure. Apparently we started the container without the --log-opt max-size setting so the logs now grow at a pretty alarming rate. I would like to avoid having to restart the service but need to limit the amount of logfiles docker is writing to disk.

Is there a way to set the max log size without restarting the container?

We are running docker 1.10.3-0~trusty on `Ubuntu 14.04


You can use logrotate. It is installed by default on Ubuntu servers and you can check /etc/logrotate.d/ for existing logrotate policies.

Following is an example policy to rotate log files daily. You can copy-paste this to /etc/logrotate.d/docker-logs

/var/lib/docker/containers/*/*.log {
  rotate 7

You can read more about logrotate here

  • 1
    Wow I did not know you can do wildcard signatures for logrotate. I was worried that having different container ids would screw up my logrotate config on restarting/starting new containers. Awesome thank you very much!! – Tigraine Nov 3 '16 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.