Interview Prep/Docker/Containers, VMs & Isolation Internals

What happens, step by step, when you run `docker run -p 8080:80 nginx`?

IntermediateConceptContainers, VMs & Isolation Internals
Answer
  1. CLI sends the request to dockerd over /var/run/docker.sock.
  2. If nginx:latest is not local, dockerd pulls manifest and layers from the registry.
  3. Layers are unpacked via containerd snapshotter and an overlay mount is prepared with a new writable layer.
  4. dockerd creates the container config, network namespace, veth pair attached to docker0, and an iptables DNAT rule for 8080 to the container IP:80.
  5. containerd launches containerd-shim, which calls runc to create namespaces/cgroups and exec the entrypoint.
  6. runc exits; the shim stays as the parent and holds stdio.
All Docker questions Roadmap: Docker & containers

More on Containers, VMs & Isolation Internals