← All notes

Docker logging drivers: json-file is the default, local rotates logs; set log-driver and log-opts

Answer: Set a default in daemon.json with "log-driver" and "log-opts", or per container with docker run --log-driver ... --log-opt NAME=VALUE. The default json-file driver performs no log-rotation, so use the local driver, or max-size and max-file options, to prevent disk-exhaustion.

Configuration

{
  "log-driver": "json-file",
  "log-opts": { "max-size": "10m", "max-file": "3" }
}
sudo systemctl restart docker
docker run --log-driver none alpine
docker logs -f --since 42m -n 100 -t <CONTAINER>

Rules

Common drivers

| Driver | Description | |---|---| | none | No logs are available, and docker logs does not return any output | | local | custom format designed for minimal overhead; performs log-rotation by default | | json-file | logs formatted as JSON; the default | | syslog, journald | the matching daemon must be running on the host machine |

Delivery mode

The default is direct, blocking delivery from container to driver. mode=non-blocking stores messages in an intermediate per-container buffer sized by max-buffer-size, which prevents applications from blocking due to logging back pressure; when the buffer is full, new messages will not be enqueued.

Reading logs

docker logs batch-retrieves logs present at the time of execution. --follow keeps streaming new STDOUT and STDERR output, --since and --until take a timestamp or a relative value like 42m, -n/--tail sets the number of lines from the end, and -t shows timestamps.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker docs, Configure logging drivers; Docker docs (CLI reference), docker container logs. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker docs, Configure logging drivers; Docker docs (CLI reference), docker container logs. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc.

Cite this

Permanent ID: iil:note:5eghpx4t

iinventedlight. 2026. "Docker logging drivers: json-file is the default, local rotates logs; set log-driver and log-opts." iinventedlight Library, iil:note:5eghpx4t, version of 2026-11-18. https://iinventedlight.com/library/notes/docker-logging-drivers/. License: CC-BY-4.0.

@misc{iil_note_5eghpx4t,
  author = {{iinventedlight}},
  title = {{Docker logging drivers: json-file is the default, local rotates logs; set log-driver and log-opts}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/docker-logging-drivers/},
  note = {Permanent ID iil:note:5eghpx4t. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-logging-drivers.md.