This page looks best with JavaScript enabled

Limit docker log file size

 ·  ☕ 1 min read  ·  🤖 Alexander Chernov

If you are running docker with default settings, you will probably find one day that the disk space on your machine begin to approach 100% state.

That’s because by default, docker will log all stdout from the containers to a log files, and it won’t rotate nor trim them.

Luckily there is a quick solution to that

edit (or create) config file

1
2
3
4
5
6
{
  "log-driver": "local",
  "log-opts": {
    "max-size": "100m"
  }
}

and restart the docker service.

This will limit maximum log file size for the container to 100mb.


Alexander Chernov
WRITTEN BY
Alexander Chernov