Cookie Consent by TermsFeed

Rotating Docker log files

Rotating Docker log files

Sometimes containers log a lot of things, and the logfile can become huge.

This happens because containers aren’t supposed to run for a long time but to be created/disposed regularly. Here’s how to fix this.

You have to instruct Docker, at launch, and tell how much you want the log file to grow before rotating and how many old logs you want to keep.

For example,

--log-opt max-size=50m --log-opt max-file=5

will limit log files to 50 MBytes and keep 5 log files, so total occupied space will be 250 MB.

(this article is a copy of the Italian version published on my Italian blog)

See also