C.W.K.
Stream
Lesson 02 of 07 · published

VM vs Container — Kernel-sharing vs Hypervisor

~18 min · foundations, isolation

Level 0Container Curious
0 XP0/36 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Two ways to isolate a workload

Both VMs and containers solve the same problem: run multiple workloads on one machine without them stepping on each other. They take fundamentally different approaches.

Virtual Machines — full OS per instance

A hypervisor (VMware ESXi, KVM, VirtualBox, Hyper-V) sits between hardware and guest VMs. Each VM runs a complete operating system: its own kernel, its own init system, its own userland. Isolation is hardware-enforced — VMs can't see each other's memory or syscalls.

Containers — shared kernel, isolated namespaces

A container shares the host's kernel. Isolation is achieved with Linux namespaces (separate views of PIDs, network, mounts, hostnames, IPC, user IDs) and cgroups (CPU/memory/IO limits). No guest OS. No hypervisor. Just a bundle of processes that think they are alone on a machine.

The trade-off table

AspectVMContainer
BootMinutesMilliseconds
Image sizeGBs (full OS)MBs (just app + libs)
Density~10 per host100s per host
IsolationStrong (separate kernels)Process-level (shared kernel)
OverheadHeavyNegligible
OS flexibilityAny OSLinux on Linux host

Most application workloads — web services, databases, batch jobs — fit comfortably inside container isolation. Use VMs when you need different kernels, hard isolation between tenants, or a Windows guest on Linux.

Code

See the kernel sharing for yourself·bash
# On a Linux host
uname -r
# 6.5.0-1018-aws

# Inside a container
docker run --rm alpine uname -r
# 6.5.0-1018-aws    ← same kernel!

# A VM would print something completely different —
# the guest's own kernel, not the host's.

External links

Exercise

Your team has a workload: 50 Python web services and 3 small Postgres databases. Argue — in 4-5 sentences — for either a VM-per-service architecture or a container-per-service architecture. Mention boot time, density, isolation requirements, and one operational consideration (logging, patching, or scaling).

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.