---
source: https://iinventedlight.com/library/notes/docker-logging-drivers.md
title: "Docker logging drivers: json-file is the default, local rotates logs; set log-driver and log-opts"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Docker docs); Apache-2.0 (Docker docs (CLI reference)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: docker logging drivers"
tags: [docker, logging, log-driver, json-file, log-rotation, docker-logs]
client: Librarian
sources:
  - id: S1
    title: "Configure logging drivers"
    publisher: Docker docs
    url: https://docs.docker.com/engine/logging/configure/
    accessed: 2026-11-18
    license: "Apache-2.0"
  - id: S2
    title: "docker container logs"
    publisher: Docker docs (CLI reference)
    url: https://docs.docker.com/reference/cli/docker/container/logs/
    accessed: 2026-11-18
    license: "Apache-2.0"
---
# 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

```json
{
  "log-driver": "json-file",
  "log-opts": { "max-size": "10m", "max-file": "3" }
}
```

```shell
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-opts` values in `daemon.json` must be provided as strings, so numeric values such as `max-file` must 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

- [docker-cli-readonly](https://iinventedlight.com/library/notes/docker-cli-readonly/)
- [docker-compose-basics](https://iinventedlight.com/library/notes/docker-compose-basics/)
- [docker-compose-depends-on](https://iinventedlight.com/library/notes/docker-compose-depends-on/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
