Skip to main content

Docker Daemon

The Docker daemon (dockerd) is the background service that manages images, containers, networks, and volumes. The docker CLI is only a client that sends API requests to it, usually over the Unix socket /var/run/docker.sock.

What the daemon does

When you run docker run nginx, the CLI sends a REST request to dockerd. The daemon pulls the image if needed, prepares networking and storage, and asks containerd to start the container, which uses runc to create namespaces and cgroups.

flowchart TD CLI[docker CLI] --> D[dockerd] D --> C[containerd] C --> R[runc] R --> P[Container process] classDef a fill:#DBEAFE,color:#1E293B classDef b fill:#D1FAE5,color:#1E293B class CLI a class D,C,R,P b

Kubernetes talks to containerd directly through CRI, which is why it could drop Docker as a runtime and still run Docker-built images.

The socket

Bash
ls -la /var/run/docker.sock
# srw-rw---- 1 root docker ... /var/run/docker.sock
curl --unix-socket /var/run/docker.sock http://localhost/containers/json

Only root and members of the docker group can use it.

Configuration

JSON
{
"log-driver": "json-file",
"log-opts": { "max-size": "100m", "max-file": "3" },
"storage-driver": "overlay2",
"live-restore": true
}
  • log-opts rotates container logs.
  • storage-driver selects overlay2, the recommended driver on modern Linux.
  • live-restore keeps containers running while the daemon restarts.
Bash
sudo systemctl status docker
sudo systemctl restart docker
sudo journalctl -u docker.service -f
docker info

Troubleshooting

Symptom Fix
Cannot connect to the Docker daemon sudo systemctl start docker
permission denied on socket Add user to docker group, log in again
Fails after config edit Validate daemon.json syntax
No space left on device docker system prune after reviewing
Security

Access to the Docker socket is effectively root on the host. Never mount it into untrusted containers, and never expose it over TCP without mutual TLS.

Tip

Enable live-restore in production so daemon upgrades do not stop containers.

Frequently Asked Questions

Where does the docker CLI end and the daemon begin?

The CLI is a thin client that sends API requests. The daemon does the work: pulling layers, managing networks and volumes, and coordinating containerd and runc. That is why the CLI can target remote daemons or other clients.

Why is mounting docker.sock into a container dangerous?

Anyone who can call the daemon can start a privileged container with the host filesystem mounted, which is root on the host. If a tool needs Docker API access, use a restricted proxy or a rootless alternative.

What does live-restore do?

It keeps running containers alive while dockerd is stopped or restarted, which allows daemon upgrades without downtime for containers.

Found a mistake, an outdated step or a broken link?