Logrotate and Docker: Why and How?
2025-09-05
Introduction
Logrotate is a powerful tool for log management in Linux, but its interaction with Docker has its own specifics.
This guide explains how to properly use logrotate with Docker containers and when it’s better to rely on Docker’s built-in log management tools.
Docker Containers and Logs
Docker collects logs from the standard output streams (stdout and stderr) of containers and, by default, stores them as JSON files:
/var/lib/docker/containers/\<container\_id>/\<container\_id>-json.log
If a container generates a lot of logs, these files can take up gigabytes and quickly consume all available disk space.