Step 01 of 06
Understand the idea
A container runs a program with limits that control what it can see and use. Unlike a virtual machine, it shares the host computer’s operating-system kernel. You will learn what that means for speed, compatibility, and security.
Key technical ideas
Namespaces limit what a process can see
Namespaces change what a process can see. For example, a PID namespace gives Beacon its own process list, and a network namespace gives it its own network settings. Mount, UTS, IPC, and user namespaces provide separate views of files, hostnames, shared memory, and user IDs. The container still uses the host’s kernel.
Cgroups limit resource use
Control groups (cgroups) limit how much of the computer a container can use. Limits can cover memory, CPU, number of processes, and disk input or output. If a container exceeds its memory limit, the system may stop it. Kubernetes often reports this as OOMKilled.
Image layers can be shared
A container image is made of read-only layers. A running container adds a writable layer on top. Containers using the same image can share its read-only layers instead of copying all the files again. Data written to a container’s writable layer can be lost when the container is removed, so use a volume for data you need to keep.
Containers and virtual machines isolate differently
A virtual machine starts its own operating-system kernel. A container shares the host computer’s kernel. Containers usually use fewer resources, while virtual machines provide a separate operating-system boundary. Each has different security and performance trade-offs; choose based on what the application needs.
docker run --rm --name tiny alpine:3.20 sh -c 'echo "inside pid=$$"; hostname; cat /proc/1/status | head -5'
docker inspect tiny 2>/dev/null || echo "container is gone"The Alpine process has its own hostname and process view while it runs, then disappears because --rm removes the container metadata. The host did not boot a new OS. It started sh with a different view of the same kernel.
Containers and VMs, without slogans
| Question | Container | Virtual machine |
|---|---|---|
Kernel | Shares the host kernel | Runs a guest kernel |
Startup | Usually milliseconds | Seconds to minutes |
Isolation | Namespaces, cgroups, LSMs | Hypervisor boundary |
Filesystem | Image layers plus writable top | Virtual disk |
Best fit | Repeatable app packaging | Strong OS separation |
Technical terms used at work
Namespace — A kernel boundary that gives a process a private view of one resource family.
Cgroup — A kernel accounting and limit mechanism for CPU, memory, process count, and I/O.
Root filesystem — The directory tree mounted at
/for the process inside the container.OCI — The Open Container Initiative standards for image layout and runtime behaviour.
