Log rotation and retention budgets
Worked example
This is an offline lesson. Data are fictional and Docker commands are unexecuted. Any optional execution requires an authorized disposable VM, a verified context, synthetic data, restricted access and no external transmission. Do not collect secrets or private output. Before any authorized optional observation, verify the effective daemon endpoint including overrides, exact object ID and observation window. Bound collection time and output bytes; do not generate resource pressure or export private telemetry. Mark unavailable measurements NOT RUN.
Illustrative per-container settings, not a command to execute:--log-driver=json-file --log-opt max-size=10m --log-opt max-file=38 containers x 3 files x nominal 10 MB = 240 MB nominal budgetAt 2 MB/min per container: 30 MB / 2 MB/min = about 15 minAlternative rate: 0.5 MB/min -> about 60 minFor json-file, configure max-size and max-file together; by default the driver does not rotate by size. The local driver rotates by default. The example uses consistent nominal MB units for estimation, not exact disk accounting. Record the active file, rotation boundary, compression if applicable, metadata and concurrent writes when measuring actual usage. A daemon default applies to newly created containers, not automatically to existing ones. In a reviewed deployment, recreate only the affected services with a rollback plan; do not edit or truncate engine-managed log files. For longer retention, design an authorized collector with storage quotas, access restrictions, deletion policy and monitoring of delivery failures. The practice yields a nominal 240 MB across twelve containers and roughly 20 minutes per container at the stated rate. These are size/rate estimates, not a minimum retention guarantee or a host disk quota. Include other disk users and delivery caches in a real capacity review.
Common mistake
Increasing max-file alone does not establish a time-based retention guarantee. A traffic spike can consume the budget much faster.
Manual practice
Estimate the nominal disk budget for 12 containers with 4 files of 5 MB each. At 1 MB/min per container estimate the history; list two reasons the measured result can differ.
Worksheet: lab-fixtures/docker-observability/02-log-rotation/scenario.txt.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Log rotation and retention budgets — Knowledge check
Interpret synthetic observability evidence and choose safe diagnostic actions.
What is the nominal budget for 12 containers with four 5 MB files each?
A service doubles its log rate with unchanged rotation. What happens to estimated history duration?
What happens to existing containers after changing the daemon logging default?