Before you start: Linux Networking
On this page

Docker Daemon Configuration

dockerd reads /etc/docker/daemon.json at startup. Most settings require a daemon restart (systemctl restart docker) to take effect — with one key exception (live-restore). Use docker info to verify the running configuration, and dockerd --validate to syntax-check before restarting.

0/0 checks

1. daemon.json Reference

A fully-annotated example covering the settings you'll actually configure in production:

{
  "storage-driver": "overlay2",

  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m",
    "max-file": "3"
  },

  "default-runtime": "runc",
  "runtimes": {
    "nvidia": {
      "path": "nvidia-container-runtime",
      "runtimeArgs": []
    }
  },
  "exec-opts": ["native.cgroupdriver=systemd"],

  "insecure-registries": [],
  "registry-mirrors": [],
  "max-concurrent-downloads": 10,
  "max-concurrent-uploads": 5,

  "live-restore": true,

  "metrics-addr": "127.0.0.1:9323",
  "experimental": false,
  "debug": false,

  "userns-remap": "",
  "no-new-privileges": false,

  "data-root": "/var/lib/docker"
}

After editing:

# Validate syntax before restarting
dockerd --validate --config-file /etc/docker/daemon.json

# Restart the daemon
sudo systemctl restart docker

# Confirm settings applied
docker info

2. Storage Driver

The storage driver controls how image layers are stored and the container writable layer is managed.

# Check the current storage driver
docker info | grep "Storage Driver"

overlay2 (default since Docker 18.09) is the right choice for all modern Linux kernels (≥ 4.0). It uses the kernel's native OverlayFS — no extra daemons, no kernel modules, and better performance than the alternatives.

Driver Status Notes
overlay2 ✅ Default Use this. Requires kernel 4.0+ and an xfs/ext4 data root
devicemapper ⚠️ Legacy Required Docker CE 17.x era. Needs loop-lvm (bad for prod) or direct-lvm config. Avoid.
btrfs Niche Use if your data-root is on a btrfs filesystem and you want snapshotting at the FS level
zfs Niche Use if data-root is on ZFS. Requires zfs-dkms package

Changing the storage driver wipes existing images and containers — all layers are driver-specific. Migrate to overlay2 on a fresh host or after backing up container data.

You change storage-driver from overlay2 to btrfs and restart Docker. What happens to your existing images?


3. Log Drivers

Default driver. Container stdout/stderr are written to JSON files at /var/lib/docker/containers/<id>/<id>-json.log.

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m",
    "max-file": "3"
  }
}

max-size — rotate when a log file reaches this size. max-file — keep this many rotated files. With the above settings, max disk usage per container is 300 MB.

Pros: docker logs works. Logs survive container restarts. Simple to debug.

Cons: Without rotation options, logs grow without bound. Rotation is not compressed — raw JSON. No central aggregation without a log shipper (Filebeat, Promtail) reading from the host paths.

Forwards container logs to systemd's journal. No files written in Docker's directory.

{
  "log-driver": "journald"
}

Read logs via:

# By container name
journalctl CONTAINER_NAME=myapp

By container ID

journalctl CONTAINER_ID=abc123

Follow live

journalctl -f CONTAINER_NAME=myapp

Pros: Inherits journald's built-in rotation, compression, and rate-limiting. Good for systemd-managed hosts where you're already reading other service logs via journald.

Cons: docker logs still works, but only retrieves logs from the journal — if the journal is rotated, older entries are gone from docker logs too. Not portable to non-systemd hosts.

Ships logs directly to Fluentd or Fluent Bit. Docker does not buffer to disk — log delivery is synchronous.

{
"log-driver": "fluentd",
"log-opts": {
"fluentd-address": "localhost:24224",
"fluentd-async": "true",
"tag": "docker.{{.Name}}"
}
}

fluentd-async: true — buffer locally if Fluentd is unreachable instead of blocking container I/O. Use this in production.

Trade-off: docker logs stops working. Once you switch to fluentd, container logs are sent directly to the Fluentd endpoint and not stored locally. You can only read them from whatever Fluentd forwards to (Elasticsearch, Loki, S3).

Use case: Production environments with a centralized logging pipeline where you don't want local log files consuming disk.


4. Runtime Configuration

{
  "default-runtime": "runc",
  "runtimes": {
    "nvidia": {
      "path": "nvidia-container-runtime",
      "runtimeArgs": []
    },
    "kata": {
      "path": "/usr/bin/kata-runtime",
      "runtimeArgs": []
    }
  },
  "exec-opts": ["native.cgroupdriver=systemd"]
}

default-runtime — the OCI runtime used when no --runtime flag is specified. runc is the standard. crun (written in C, faster startup) is a drop-in replacement.

runtimes — register additional runtimes. Use them per-container:

# Use NVIDIA runtime for GPU workloads
docker run --runtime=nvidia --gpus all cuda-app

# Use Kata containers for hardware isolation
docker run --runtime=kata secure-workload

exec-opts: native.cgroupdriver=systemd — this is critical if you're running Kubernetes on this host. Kubernetes (kubelet) defaults to the systemd cgroup driver. If Docker uses cgroupfs while kubelet uses systemd, you get split cgroup hierarchies which break pod resource accounting and eviction. Always set systemd on K8s hosts.

# Verify after restart
docker info | grep -i cgroup
# Should show: Cgroup Driver: systemd

5. Registry Configuration

{
  "insecure-registries": ["registry.internal:5000", "10.0.0.10:5000"],
  "registry-mirrors": ["https://mirror.gcr.io", "https://registry-1.docker.io"],
  "max-concurrent-downloads": 10,
  "max-concurrent-uploads": 5
}

insecure-registries — allow Docker to pull from registries using HTTP or self-signed TLS without certificate validation. Needed for private registries on internal networks. Never list public registries here.

registry-mirrors — pull-through cache for Docker Hub. When you docker pull nginx, Docker tries the mirror first. If the mirror has it cached, you get the image faster and don't count against Docker Hub's rate limits (100 pulls/6h for unauthenticated, 200 for free accounts).

max-concurrent-downloads — number of image layers pulled in parallel. Default is 3. Increase to 10 on nodes with high bandwidth to speed up initial image pulls during cluster provisioning.

Your CI runners are hitting Docker Hub rate limits (429 Too Many Requests). What's the fastest fix that doesn't require changing the registry?


6. Live Restore

{
  "live-restore": true
}

With live-restore: true, running containers continue running when the Docker daemon is restarted or upgraded. Without it, systemctl restart docker stops all containers.

# Upgrade Docker without downtime
sudo apt-get install docker-ce docker-ce-cli  # install new version
sudo systemctl restart docker                  # containers stay running

Limitations:

  • Containers that need to apply kernel-level settings (new seccomp profile, added capabilities) must be restarted manually — live-restore can't retrofit those.
  • Networking changes (new bridge options, --dns changes) apply only to new containers.
  • Not compatible with userns-remap changes — those require a full container restart.

Verify it worked:

docker inspect <container_id> | jq '.[0].State.Running'
# Should return true after daemon restart

7. Metrics and Debug

{
  "metrics-addr": "127.0.0.1:9323",
  "experimental": false,
  "debug": false
}

metrics-addr — exposes a Prometheus-compatible /metrics endpoint on the specified address. Includes:

  • engine_daemon_container_actions_seconds — time spent on container operations
  • engine_daemon_image_actions_seconds — image pull/push timing
  • go_goroutines — number of goroutines in the daemon

Scrape it from Prometheus:

- job_name: docker
  static_configs:
    - targets: ['localhost:9323']

debug: true — enables verbose logging in journald (journalctl -u docker -f). Logs every API call and internal state transition. Only enable when diagnosing a specific issue — it's extremely noisy.

experimental: true — enables features under active development. Some features start experimental and graduate to stable (e.g., BuildKit, rootless Docker improvements). Check the Docker release notes before enabling in production.


8. Security Defaults

{
  "userns-remap": "default",
  "no-new-privileges": false,
  "seccomp-profile": "/etc/docker/seccomp.json"
}

userns-remap: "default" — enables user namespace remapping. Container UID 0 maps to an unprivileged host UID (e.g., 165536). A container breakout lands as an unprivileged user on the host instead of root. "default" creates a dockremap user and subuid/subgid ranges automatically.

Conflict: userns-remap breaks containers that use --privileged, volume mounts of /proc or /sys, and some Docker-in-Docker setups. Test before enabling on existing hosts.

no-new-privileges: true — applies PR_SET_NO_NEW_PRIVS to all containers via the daemon, equivalent to --security-opt=no-new-privileges on every docker run. Prevents privilege escalation via setuid binaries inside containers (e.g., sudo).

seccomp-profile — apply a custom seccomp profile to all containers. Docker ships a default profile that blocks ~40 dangerous syscalls. A stricter custom profile can block additional syscalls your workloads don't need.

# See what the default profile blocks
docker run --rm alpine strace ls 2>&1 | head -5
# Or inspect the built-in profile
docker info | grep Seccomp

You enable userns-remap: "default" and find that your Postgres container's volume data is now inaccessible (permission denied). Why?

Edit this page on GitHub ↗