Lesson 1 of 9 · 24m
Containers Are Processes, Not Virtual Machines
Use namespaces, cgroups, and the shared kernel model to predict what containers can see, change, and break.
The first expensive container mistake I see teams make is treating a container as a small virtual machine. It is not. A container is a collection of Linux processes wearing kernel-enforced blinders: namespaces decide what the process can see, cgroups decide how much it can consume, and security mechanisms such as capabilities, seccomp, LSMs, and read-only mounts constrain what it may do. All containers on a host share the same kernel.
The mental model
Start a container and inspect it as a process:
docker run -d --name web nginx:1.27
pid=$(docker inspect -f '{{.State.Pid}}' web)
ps -o pid,ppid,user,comm,args -p "$pid"
sudo ls -l "/proc/$pid/ns"You will see links such as mnt:[4026532448], net:[4026532450], and pid:[4026532452]. Those magic-looking numbers are namespace instances. The process is ordinary; its view of the system is not.
Namespaces isolate visibility, not truth
Different namespaces answer different questions:
mnt which filesystems and mounts are visible
pid which process IDs exist
net which interfaces, routes, and firewall state exist
ipc which shared-memory and message-queue objects exist
uts which hostname appears
user how UID/GID numbers map between container and host
cgroup which cgroup hierarchy appearsA container can have its own private process tree while sharing the host kernel completely. That is why ps inside the container is quiet, but host-wide kernel logs, driver bugs, and kernel exploits are not magically isolated.
cgroups are accounting and enforcement
Control groups throttle and measure CPU, memory, IO, and process counts. Docker writes limits into cgroup v2 paths similar to:
docker run --memory=256m --cpus=1.5 --pids-limit=200 nginx:1.27
cat /sys/fs/cgroup/system.slice/docker-$(docker inspect -f '{{.Id}}' web).scope/memory.maxLimits are not security boundaries by themselves. They protect neighbors from resource exhaustion more than they protect the host from malicious code.
Why this matters on day one
Containers are fast because there is no guest kernel boot, virtual hardware layer, or duplicate operating system. They are also sharp because there is no guest kernel boundary. When you choose --privileged, mount /var/run/docker.sock, or run everything as UID 0, you are weakening boundaries around ordinary host processes — not merely weakening a pretend VM.
Field notes
docker execenters existing namespaces; it does not SSH into a separate machine.- A container UID 0 is host UID 0 unless user namespaces remap it.
- Kernel version, syscall availability, and LSM policy are host properties.
- The container image supplies files, not a kernel.
uname -rinside a container reports the host kernel. - Most production confusion disappears once you ask: which namespace, which cgroup, which UID mapping, which mount?
Was this lesson helpful?