Skip to main content
Skip table of contents

Docker Logging

Question

How does Docker handle container logs, and what are the best practices for log management?

Answer

Applications running within a Docker container typically do not generate log files; instead, they direct all log messages to standard output. The handling of these messages is managed by Docker itself. To facilitate this, Docker introduces the concept of “logging drivers” (documentation), which enable the use of specialized third-party implementations (documentation).

By default, Docker employs the standard built-in logging driver: json-file. This driver creates a JSON file on the host system and captures all output from the container, writing it to this file. It can be configured to support log rotation, as detailed in the documentation.

Warning: The default configuration provided by a fresh Docker installation does not implement log rotation! This poses a significant risk, as the log file can eventually consume all available disk space.

We recommend utilizing a centralized logging solution with a custom logging driver, which is standard practice in cloud hosting platforms like AWS. If such an option is unavailable, the default logging driver should be used with a properly configured log rotation.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.