Published signals

Taming Docker Log Growth: Rotation and Cleanup Strategies

Score: 8/10 Topic: Docker log rotation and cleanup

Docker's default json-file log driver can fill disks with multi-GB logs, causing outages. This post explains how to configure log rotation and clean up existing logs to prevent disk exhaustion. A must-read for anyone managing Docker hosts in production.

Docker containers can silently consume disk space through unbounded log files. The default json-file log driver does not rotate logs, so a busy container can generate tens of gigabytes of logs, eventually filling the root partition and triggering alerts. This article addresses the problem by showing how to configure log rotation at the Docker daemon level or per-container, using options like max-size and max-file. It also covers manual cleanup techniques for existing logs, including truncating files and using docker system prune. The post emphasizes proactive configuration to avoid emergency situations. For DevOps teams, implementing these practices is essential for maintaining stable and reliable containerized environments. The guidance is practical and directly applicable to production systems, making it a valuable reference for engineers facing similar issues.