Skip to content

What is a container, really?

Select an icon to see what it is.

Step 6 of 6

Its filesystem is an overlay mount

dockerd mounts the image layers read-only and adds a writable layer, all as one overlay mount under /var/lib/docker/overlay2. runc makes that mount the container's root. That is why the container sees its own files.

PrevNext

mount (inside the host)

overlay on /var/lib/docker/overlay2/<id>/merged type overlay
lowerdir=<image layers>
upperdir=/var/lib/docker/overlay2/<id>/diff
workdir=/var/lib/docker/overlay2/<id>/work

Try it yourself

Start a container and look at it from the host.

$ docker run -d --name web nginx
$ docker top web
$ ps -ef | grep "nginx: master"
$ docker inspect --format '{{.State.Pid}}' web
$ sudo ls -l /proc/$(docker inspect --format '{{.State.Pid}}' web)/ns
$ docker rm -f web

Quiz

1. What is a container on the host?
2. Why is nginx PID 1 inside the container but a different PID on the host?
3. Which component builds the container from an OCI config?