Containers vs Virtual Machines & Docker Architecture
"It works on my machine" was the bane of software engineering. Docker solved this forever by packaging an application together with its runtime, dependencies, system libraries, and configurations into a…
Lesson 4 of 26 · Module: Docker
15 min read · Source notes — Videos: Docker Full Course & Docker Mastery
"It works on my machine" was the bane of software engineering. Docker solved this forever by packaging an application together with its runtime, dependencies, system libraries, and configurations into a portable, reproducible image.

Instructor explaining container isolation compared to legacy hypervisor architectures.
Containers vs Virtual Machines: The Technical Difference
| Feature | Virtual Machine (VM) | Container (Docker) |
|---|---|---|
| Kernel | Contains its own full Guest OS kernel | Shares the Host OS Linux kernel |
| Isolation Level | Hardware-level (via Hypervisor Type 1/2) | Process-level (via Linux kernel namespaces) |
| Startup Time | Minutes (boots full OS, systemd, drivers) | Milliseconds (instantiates a sandboxed process) |
| Storage Footprint | Gigabytes (10GB - 40GB per VM) | Megabytes (5MB Alpine to ~150MB Debian slim) |
| Resource Usage | Pre-allocated RAM & CPU slices | Dynamic: consumes only what process uses |

Detailed visual comparison of host hypervisors vs container runtime daemons.
How the Linux Kernel Creates Containers
Docker is not a virtual machine. A container is simply an ordinary Linux process running with kernel constraints:
- Namespaces (Isolation):
pid: Process IDs (container PID 1 appears as a regular PID on host)net: Dedicated network interfaces, IP addresses, and routing tablesmnt: Isolated filesystem mounts and root directory pivotipc: Inter-process communication memory queuesuts: Hostname and domain name isolationuser: User ID and Group ID mappings - cgroups (Control Groups - Resource Limits): Enforces hardware constraints such as
--memory="512m"and--cpus="1.5". If a container exceeds its memory limit, the Linux kernel invokes the OOM (Out Of Memory) killer.
Docker Engine Architecture
1. Docker CLI Client: Terminal utility (`docker build`, `docker run`)
↓
REST API (Unix Socket: /var/run/docker.sock)
↓
2. Docker Daemon (dockerd): Manages images, containers, networks, volumes
↓
gRPC
↓
3. containerd & runc: OCI-compliant runtime that interfaces with Linux kernel primitivesKeep going: ← Lesson 3 · Lesson 5 → · Module overview · Track it in the Self Guide
Finished this one?
Part of Self Guide · Stage 3: Containers with Docker. Progress is saved in this browser.



