log rotation

Capping log files by size or count so old lines are deleted before they fill the disk.

Without it, logs can fill the disk and take down every service on the host.

In more detail

With the json-file driver, container logs grow forever unless you set max-size and max-file, in daemon.json or per container. A chatty service filling the disk is a common and entirely avoidable outage. The local driver rotates by default.

Examples

A twelve-factor app never rotates its own log files, because it writes none: the bad variant in the course writes quotes.log and must now rotate it, while the good variant leaves storage to the platform.
docker run --log-opt max-size=10m --log-opt max-file=3 ...

Related terms

Taught in

References

Certification courses