Winter Semester 2026–27 · VIT-AP · BACSE106 · Operating Systems · Dr. Krithika L.B

Containers and Docker, hands on

Namespaces, cgroups and image layers explained step by step — with a quiz.

Module 5 Session 5.6 Lesson 1 of 1

Containers and Docker, hands on

What really happens when you type docker run.

docker pull ubuntu:22.04 downloads read-only layers (base files) from a registry.

docker run asks the kernel for new PID, mount, network, UTS, IPC and user namespaces — the container gets its own view of processes, files and network.

A control group is created; flags such as --memory=256m --cpus=0.5 become cgroup limits enforced by the scheduler and memory manager.

The image layers are stacked with a writable layer on top (copy-on-write). Deleting the container discards only that layer.

The command (e.g. bash) starts as PID 1 inside its namespace — but on the host it is an ordinary process with a normal PID, visible with ps.

Seeing the same process from both sides
$ docker run -d --name web nginx
$ docker exec web ps -e | head -3       # inside: nginx is PID 1
    PID TTY          TIME CMD
      1 ?        00:00:00 nginx
$ ps -e | grep nginx | head -1          # on the host: a normal PID
  23817 ?        00:00:00 nginx
Quick check

Which kernel feature hides other containers' processes?

Namespaces control what a process can see.

Which feature stops a container from using all the RAM?

cgroups control what a process can use.

Containers start faster than VMs mainly because…

They share the already-running host kernel.