Lesson 11 of 30
The `docker` command never builds an image or starts a container itself — it asks a background process to, over a socket. Whoever can reach that socket has the same power the CLI does, which is a real, common security footgun.
10 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 3
A CI job mounts `/var/run/docker.sock` into a build container so it can launch a sibling container. What does that actually grant the build container?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
docker run, docker build, docker ps — none of these commands do the actual work. The docker binary is a thin client: it takes what you typed, sends it as a request to a long-running background process called the daemon (dockerd), and prints back whatever the daemon replies. The daemon is where the real work happens — pulling layers, starting the container's namespaces and cgroups, managing networks and volumes, storing images.
Client and daemon talk over a socket, by default a Unix domain socket at /var/run/docker.sock on Linux (a named pipe on Windows; Docker Desktop on macOS/Windows actually runs the daemon inside a small Linux VM and forwards to it). This is a genuine client-server split, not just an implementation detail — the CLI has no special privilege of its own. Anything that can write to that socket can do everything the CLI can do, because as far as the daemon is concerned, a request is a request regardless of what sent it.
docker run -v /var/run/docker.sock:/var/run/docker.sock docker:cli \
docker run -it --privileged --pid=host alpine nsenter -t 1 -m -u -n -i sh
This is a real pattern seen in CI setups (often to let a build step launch sibling containers) and it's also a well-known container-escape technique. The mounted socket doesn't give the inner container "extra Docker access" — it gives it a direct line to the host's daemon, which can then be asked to start a new, --privileged container that mounts the host's root filesystem and drops into it. Nothing about this requires exploiting a bug; every step is the daemon doing exactly what it's designed to do, for a client that happens to be running inside a container instead of on the host shell.
docker context and DOCKER_HOST don't change what a command means — they change which daemon receives it. docker context use remote-server (or setting DOCKER_HOST=ssh://user@remote-server) points the exact same client at a daemon running on a different machine entirely; docker ps then lists that host's containers, not the local one.dockerd -H tcp://0.0.0.0:2375 (no s, no certs) is a known, actively-scanned-for misconfiguration — anyone who can reach that port can run arbitrary containers on the host."Why is mounting /var/run/docker.sock into a CI job risky?" is a real security-review question, and the strong answer names the actual mechanism — socket access equals daemon-client equivalence equals host control — rather than a vague "it's a security risk." It's also the natural first question behind "how would you run Docker safely inside CI," which this track's later rootless-containers lesson answers directly.