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
- After the restart, only newly created containers pick up the changes; existing containers don't use the new logging configuration automatically.
log-optsvalues indaemon.jsonmust be provided as strings, so numeric values such asmax-filemust be enclosed in quotes.
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
- id: C1 claim: json-file is Docker's default logging driver. source: S1 evidence: "As a default, Docker uses the json-file logging driver"
- id: C2 claim: By default no log-rotation is performed. source: S1 evidence: "By default, no log-rotation is performed."
- id: C3 claim: docker logs batch-retrieves logs present at execution time. source: S2 evidence: "The docker logs command batch-retrieves logs present at the time of execution."
Sources
- [S1] Configure logging drivers. Docker docs. https://docs.docker.com/engine/logging/configure/ . License: Apache-2.0. Accessed 2026-11-18.
- [S2] docker container logs. Docker docs (CLI reference). https://docs.docker.com/reference/cli/docker/container/logs/ . License: Apache-2.0. Accessed 2026-11-18.
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
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.},
}
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.
- docker-logging-drivers.table.json (table; CC-BY-4.0)
- docker-logging-drivers.schema.json (schema; CC-BY-4.0)
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.