Docker logo

Docker Container Logs

Application stdout/stderr output captured from containers

Edit this page

Quick Facts

Default Path (Linux)
/var/lib/docker/containers/<id>/<id>-json.log
Default 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.log

Available 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 format

Syslog Driver

Example:

<14>Dec 20 14:32:18 dockerhost container/myapp[1234]: INFO Starting application...

Structure:

RFC 3164 or RFC 5424

Fields Reference

FieldTypeDescriptionExample
log
string
The actual log message from the container2025-12-20 14:32:18 INFO Starting application...
stream
string
Output stream (stdout or stderr)stdout
time
datetime
When Docker captured the log line2025-12-20T14:32:18.123456789Z

Parsing Patterns

Collector Configurations

fluentdyaml
1<source>
2 @type forward
3 port 24224
4 bind 0.0.0.0
5</source>
6
7# Configure Docker to use fluentd driver:
8# docker run --log-driver=fluentd --log-opt fluentd-address=localhost:24224 myapp

Configuration

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!