Logging drivers and container output
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.
# Staged read-only commands for a known lab container# Do not execute against an unknown Docker context.docker inspect --format '{{.HostConfig.LogConfig.Type}}' bm-observedocker logs --since 10m --tail 50 --timestamps bm-observe# Synthetic cases (not captured output):A: driver=local, application writes stdoutB: remote driver, dual logging disabledC: application writes only /app/private.logFirst confirm the authorized context and the exact container ID or name. The first command reads its configured driver; the second bounds log retrieval by time and line count (both apply), adding timestamps. local and json-file support local log reading. For a remote driver that cannot read logs, Docker can keep a local dual-logging cache; when disabled, docker logs may fail or lack useful output. In C, change the application logging configuration to emit appropriate events to stdout/stderr instead of assuming Docker reads arbitrary files. Driver none disables container logging. Daemon logs diagnose the engine itself and are a different stream. Blocking delivery may stall application output when the sink is slow; non-blocking delivery can drop messages when its buffer fills. Evaluate loss and backpressure deliberately. A time and line limit does not bound bytes: one log line can be large. Keep a separate output-byte and execution-time budget, redact before retention, and distinguish a successful local read from confirmed remote delivery. Do not read engine-managed log files directly.
Common mistake
An empty docker logs result is not proof that the application is idle or healthy. Check the source, driver and time range before drawing a conclusion.
Manual practice
For A, B and C, identify the likely place to look for evidence. Explain what you would change for C and how you would avoid collecting private data.
Worksheet: lab-fixtures/docker-observability/01-logging-drivers/scenario.txt.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Logging drivers and container output — Knowledge check
Interpret synthetic observability evidence and choose safe diagnostic actions.
What does a logging driver select?
A remote driver cannot read logs and its dual cache is disabled. What should you check?
Which approach bounds the amount of output requested?