Limit docker log file size

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  "log-driver": "local",
3  "log-opts": {
4    "max-size": "100m"
5  }
6}

and restart the docker service.

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

Copyright

Comments