Q: A mission-critical payment service caused a host-wide outage when an unhandled application loop spewed 80GB of debug logs over the weekend. Because Docker's default logging driver was unconfigured, the `*-json.log` file in `/var/lib/docker/containers/` filled the host root filesystem to 100%, causing the Docker daemon, kubelet, and etcd to crash. You must configure global log rotation in `daemon.json`, benchmark log drivers (`json-file` vs `local`), and implement non-blocking delivery to prevent slow log writers from freezing application I/O.
Configure production-grade Docker daemon logging drivers in daemon.json. Prevent host node filesystem exhaustion using local and json-file log rotation with non-blocking buffer modes.
daemon.json. Prevent host node filesystem exhaustion using local and json-file log rotation with non-blocking buffer modes."
Want to master this scenario in a live sandbox? KodeKloud's Docker Certified Associate (DCA) Hands-On Lab Course covers this exact problem with hands-on terminal drills.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: Configure production-grade Docker daemon logging drivers in daemon.json. Prevent host node filesystem exhaustion using local and json-file log rotation with non-blocking buffer modes.
Analyze the Mechanics of Docker Default Logging Exhaustion
By default, Docker uses the json-file driver with no size limit (max-size: unlimited) and blocking I/O mode. A verbose container will continuously write to disk until host storage is exhausted, crashing host systemd daemons.
# Inspect the runaway container log on the host filesystem
ls -lh /var/lib/docker/containers/<CONTAINER_ID>/<CONTAINER_ID>-json.log
# Check filesystem usage
df -h /var/lib/docker
Configure Enterprise Log Rotation in daemon.json
Update /etc/docker/daemon.json with global log rotation parameters. Limit each log file to 50MB with a maximum of 3 rotated files, ensuring a maximum disk footprint of 150MB per container.
cat <<EOF | sudo tee /etc/docker/daemon.json
{
"log-driver": "json-file",
"log-opts": {
"max-size": "50m",
"max-file": "3",
"mode": "non-blocking",
"max-buffer-size": "4m",
"compress": "true"
}
}
EOF
Evaluate the High-Performance 'local' Log Driver
For performance-critical environments, configure Docker's internal local log driver. Unlike json-file, the local driver uses an efficient binary format, applies automatic log compression, and enforces default 20MB file limits without manual configuration.
{
"log-driver": "local",
"log-opts": {
"max-size": "20m",
"max-file": "5",
"compress": "true"
}
}
Apply Configuration Safely via SIGHUP Signal
Reload the Docker daemon configuration without stopping active containers by sending a SIGHUP signal to dockerd or executing systemctl reload docker.
# Reload daemon configuration dynamically
sudo systemctl reload docker
# Verify active daemon settings
docker info --format '{{.LoggingDriver}}'
# Verify log rotation on newly launched containers
docker run -d --name log-test alpine sh -c 'while true; do echo "test log $(date)"; sleep 0.1; done'
docker inspect log-test --format '{{json .HostConfig.LogConfig}}' | jq .
max-size and max-file rotation in daemon.json alongside mode: non-blocking ensures logs never exhaust disk space or block application execution threads."
- W
- e
- e
- l
- i
- m
- i
- n
- a
- t
- e
- d
- d
- i
- s
- k
- e
- x
- h
- a
- u
- s
- t
- i
- o
- n
- o
- u
- t
- a
- g
- e
- s
- a
- c
- r
- o
- s
- s
- o
- u
- r
- c
- o
- n
- t
- a
- i
- n
- e
- r
- f
- l
- e
- e
- t
- b
- y
- h
- a
- r
- d
- e
- n
- i
- n
- g
- `
- d
- a
- e
- m
- o
- n
- .
- j
- s
- o
- n
- `
- .
- W
- e
- c
- o
- n
- f
- i
- g
- u
- r
- e
- d
- s
- t
- r
- i
- c
- t
- 5
- 0
- M
- B
- l
- o
- g
- f
- i
- l
- e
- r
- o
- t
- a
- t
- i
- o
- n
- w
- i
- t
- h
- c
- o
- m
- p
- r
- e
- s
- s
- i
- o
- n
- a
- n
- d
- s
- e
- t
- `
- m
- o
- d
- e
- :
- n
- o
- n
- -
- b
- l
- o
- c
- k
- i
- n
- g
- `
- w
- i
- t
- h
- a
- 4
- M
- B
- b
- u
- f
- f
- e
- r
- .
- T
- h
- i
- s
- g
- u
- a
- r
- a
- n
- t
- e
- e
- s
- t
- h
- a
- t
- c
- o
- n
- t
- a
- i
- n
- e
- r
- l
- o
- g
- g
- i
- n
- g
- c
- a
- n
- n
- o
- t
- m
- o
- n
- o
- p
- o
- l
- i
- z
- e
- n
- o
- d
- e
- d
- i
- s
- k
- s
- p
- a
- c
- e
- o
- r
- d
- e
- g
- r
- a
- d
- e
- a
- p
- p
- l
- i
- c
- a
- t
- i
- o
- n
- t
- h
- r
- o
- u
- g
- h
- p
- u
- t
- d
- u
- r
- i
- n
- g
- h
- i
- g
- h
- -
- f
- r
- e
- q
- u
- e
- n
- c
- y
- l
- o
- g
- s
- u
- r
- g
- e
- s
- .
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
-
Structuring Dockerfile instructions inefficiently by copying app source before package manifests when configuring Hardening dockerd daemon
Copying code before package manifests (
package.json,go.mod,requirements.txt) invalidates the build cache on every commit, forcing slow full reinstalls. -
Neglecting the PID 1 process reap problem and omitting proper SIGTERM signal forwarding when configuring Hardening dockerd daemon
If an application runs as PID 1 without an init system (like
tini), it fails to reap zombie child processes and ignoresSIGTERMsignals, causing unclean 10s timeouts. - Assembling single-stage images containing compilers, build SDKs, and header files in production when configuring Hardening dockerd daemon Single-stage builds bloat image size by gigabytes and expose extensive package vulnerabilities; multi-stage builds isolate artifacts into minimal distroless images.
- Confusing container port forwarding on bridge networks with unisolated host networking mode when configuring Hardening dockerd daemon Bridge networking utilizes iptables NAT translations which add latency overhead, whereas host networking bypasses the network namespace entirely.