LOGBOOK

HELP

Quiz Entry - updated: 2026.11.26

Why does mounting /var/run/docker.sock into a container hand that container root on the host?

The Docker socket is the daemon's control interface; anyone who can talk to it can tell the root daemon to start a new container that mounts the host's entire filesystem — so socket access equals host root.

/var/run/docker.sock is the Unix socket the Docker client uses to command the daemon. The daemon runs as root and will build, run and configure containers on request. So being able to write to the socket is equivalent to controlling the daemon, which is equivalent to root on the host.

If an image's author talks you into mounting the socket (-v /var/run/docker.sock:/docker.sock), a process in that container can:

  1. Install just the Docker client (no daemon needed) inside the container.
  2. Point it at the mounted socket with -H unix:///docker.sock and launch a new container that bind-mounts the host root / to, say, /test, with a shell.
  3. Now browse and modify the whole host filesystem (/test/home/…, /test/etc/…) as root. The changed hostname confirms it is a fresh container with full host access.

This is a textbook container escape. The lesson: treat the Docker socket as a crown jewel. Never mount it into containers you don't fully trust; if a tool genuinely needs Docker access, use a proxy that filters the API, or rootless Docker, rather than exposing the raw socket.

A container with the Docker socket mounted installs the client, tells the root daemon to launch a container mounting host /, and gets host root

* Socket access = control of the root daemon = host root. *

Go deeper:

From Quiz: ISLAB / Docker Security | Updated: Nov 26, 2026