Docker Container Logs
Application stdout/stderr output captured from containers
Quick Facts
Default Path (Linux)
/var/lib/docker/containers/<id>/<id>-json.logDefault Format
json-file
JSON Native
Yes
Rotation
Docker log driver settings
Log Example
Default format: JSON File Driver
Example Log Entrylog
{"log":"2025-12-20 14:32:18 INFO Starting application...\n","stream":"stdout","time":"2025-12-20T14:32:18.123456789Z"}Structure:
{"log":"message","stream":"stdout|stderr","time":"ISO8601"}Paths by Platform
All
/var/lib/docker/containers/<container-id>/<container-id>-json.logAvailable Formats
JSON File Driver
Default
Example:
{"log":"2025-12-20 14:32:18 INFO Starting application...\n","stream":"stdout","time":"2025-12-20T14:32:18.123456789Z"}Structure:
{"log":"message","stream":"stdout|stderr","time":"ISO8601"}journald Driver
Example:
Dec 20 14:32:18 dockerhost container[1234]: 2025-12-20 14:32:18 INFO Starting application...Structure:
systemd journal formatSyslog Driver
Example:
<14>Dec 20 14:32:18 dockerhost container/myapp[1234]: INFO Starting application...Structure:
RFC 3164 or RFC 5424Fields Reference
| Field | Type | Description | Example |
|---|---|---|---|
log | string | The actual log message from the container | 2025-12-20 14:32:18 INFO Starting application... |
stream | string | Output stream (stdout or stderr) | stdout |
time | datetime | When Docker captured the log line | 2025-12-20T14:32:18.123456789Z |
Parsing Patterns
Collector Configurations
fluentdyaml
1<source>2 @type forward3 port 242244 bind 0.0.0.05</source>67# Configure Docker to use fluentd driver:8# docker run --log-driver=fluentd --log-opt fluentd-address=localhost:24224 myappConfiguration
Enable Logging
Configure default logging driver in daemon.json
/etc/docker/daemon.json
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3",
"labels": "production_status",
"env": "os,customer"
}
}Log Rotation
Tool: Docker log driver settings | Config: /etc/docker/daemon.json
/etc/docker/daemon.json
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "5",
"compress": "true"
}
}Use Cases
Application debugging
View application output in real-time
log
stream
Error tracking
Monitor stderr for errors
stream
log
stream = 'stderr'Container lifecycle
Track container start/stop events
log
Troubleshooting
Tested On
v27.4.0 on Ubuntu 24.04
container_expert - 2025-12-10
v27.3.1 on Debian 12
admin - 2025-11-20
Last updated: 2025-12-10 by container_expert
3 contributors198 upvotes
Validated
Community Discussions
Help improve this documentation
Found an error or want to add more examples? Contributions are welcome!