Skip to content

Commit 072889d

Browse files
committed
docs: spell out what the local log driver actually changes
The log-rotation section asserted that json-file "grows unbounded" without saying why or what local replaces it with, which is the kind of claim a reader has to go verify before acting on it. Per Docker's driver docs: json-file defaults to max-size -1 (unlimited) with max-file 1, so it does not rotate at all unless configured; local defaults to 20 MB x 5 files with compression on, capping a container at roughly 100 MB. Adds that comparison as a table, notes docker logs still works, and records the caveat that local's files are "designed to be exclusively accessed by the Docker daemon". Also stops overclaiming: Docker's docs state no preference between the two drivers, so this is presented as a better-defaults choice, with the json-file + log-opts alternative given for anyone who needs raw-JSON compatibility. Notes that the setting only affects newly created containers, which makes a post-reset moment the cheapest time to apply it.
1 parent bebd8a9 commit 072889d

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

‎docs/docker-maintenance-cheatsheet.md‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,28 @@ recreates the disk and destroys all volumes — back up first.
157157
}
158158
```
159159

160-
`local` rotates and compresses; the default `json-file` grows unbounded.
161-
Requires a Docker restart, and applies to newly created containers.
160+
Every line a container writes to stdout/stderr is stored on disk, and the default
161+
`json-file` driver **never rotates unless you tell it to** — its `max-size`
162+
defaults to `-1` (unlimited) with `max-file: 1`. A chatty dev server or a
163+
database logging every query grows that file forever, and it shows up nowhere in
164+
`docker system df`.
165+
166+
| | `json-file` (default) | `local` |
167+
|---|---|---|
168+
| Rotation | none (`max-size: -1`, `max-file: 1`) | 20 MB × 5 files |
169+
| Compression | no | yes, by default |
170+
| Cap per container | unbounded | ~100 MB |
171+
172+
`docker logs` works normally with `local`. Docker's docs do *not* state a
173+
preference between the two drivers, so this is a better-defaults choice rather
174+
than an official recommendation — the equally valid alternative is keeping
175+
`json-file` and adding `"log-opts": {"max-size": "10m", "max-file": "3"}`, which
176+
preserves compatibility if anything ever parses the raw JSON log files. With
177+
`local`, don't: Docker warns those files "are designed to be exclusively
178+
accessed by the Docker daemon".
179+
180+
Requires a Docker restart, and applies only to **newly created** containers — so
181+
the cheapest moment to change it is right after a reset, when none exist.
162182

163183
---
164184

0 commit comments

Comments
 (0)