Compare

Side-by-side on the decisions that recur: process vs thread, threads vs async, mutex vs semaphore, blocking vs non-blocking I/O, container vs VM — with when to choose each.

ContainerVirtual machine
KernelShares the host kernel (uname -r matches the host)Boots its own kernel on virtual hardware from a hypervisor
Isolation mechanismNamespaces (PID, net, mount, user…) and cgroups — kernel featuresHardware virtualisation (VT-x/AMD-V): the guest cannot see the host at all
Start time and footprintMilliseconds; MBs — it is just a process tree with a different viewSeconds; hundreds of MBs to GBs for a whole OS image
Security boundaryOne kernel bug can cross it; user namespaces and seccomp narrow the surfaceMuch stronger; VM escapes are rare and severe
Different OS insideNo — Linux containers need a Linux kernel (Docker Desktop runs a Linux VM on macOS/Windows; Windows containers need a Windows host)Yes — any guest OS the hypervisor supports
Resource limitscgroups: CPU weight, memory limit (page cache counts), PIDs, I/OFixed vCPUs and RAM assigned at boot; ballooning to adjust
Middle groundgVisor, Kata, Firecracker micro-VMs: container UX with a VM boundary
Choose this whenPackaging and density for your own trusted services: fast start, many per host, one kernel is fine.Untrusted tenants, a different kernel or OS, kernel modules, or compliance that demands a hardware boundary.