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 inforeports 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