Skip to main content
RunBook Academy

← All labs in Docker & Containers

Lab · intermediate · ~30 min

Lab 6: Configure daemon.json and observe the effect

B · Nested virtualisationC · Simulation

Objectives

  • Configure daemon.json safely
  • Enable log rotation per container
  • Disable the userland proxy
  • Enable live-restore for daemon-upgrade continuity

Prerequisites

  • Lab 5: install Docker

Objective

Apply a production-grade /etc/docker/daemon.json and verify each setting actually takes effect. Misconfigured daemon.json is a common cause of subtle production incidents.

Tasks

Task 1: Write the daemon.json

sudo tee /etc/docker/daemon.json > /dev/null <<'EOF'
{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "5"
  },
  "userland-proxy": false,
  "live-restore": true,
  "default-runtime": "runc"
}
EOF

Task 2: Validate the JSON

python3 -c 'import json,sys; json.load(open("/etc/docker/daemon.json"))'

A non-zero exit means the JSON is invalid and dockerd will not start.

Task 3: Restart the daemon

sudo systemctl restart docker
sudo systemctl status docker

A failed restart means the daemon.json is broken; journalctl -u docker --since "1 minute ago" will show the parse error.

Task 4: Verify each setting

docker info | grep -E '(Storage Driver|Logging Driver|Runtimes|Default Runtime)'
docker info | grep -i 'live restore'
# Live Restore Enabled: true

# Confirm userland-proxy is off
ps -ef | grep -c docker-proxy
# Should be 0 once you restart any containers started after the change

Task 5: Test log rotation

docker run -d --name logtest --log-opt max-size=1m --log-opt max-file=2 \
  busybox sh -c 'while true; do echo "padding $(date) $(head -c 100 /dev/urandom | base64)"; sleep 0.1; done'

sleep 90

ls -la $(docker inspect logtest --format '{{.LogPath}}' | xargs dirname)
# You should see at most 2 rotated files plus the active one

docker rm -f logtest

Expected outcome

  • docker info reports the logging driver and live-restore.
  • The userland proxy process is not running.
  • Log files rotate at 1 MB.

Cleanup

docker rm -f logtest 2>/dev/null

Verification status

Last reviewed
2026-08-09
Executed end to end
not yet run on hardware

The commands and configuration here have been reviewed against the verified software versions, but nobody has run this lab start to finish on a system meeting its prerequisites. Treat the Expected Outcome as the intended result rather than an observed one, and keep the Cleanup section to hand.