Virtualization Mechanics:
1. Containers vs Virtual Machines (VMs):
- Virtual Machines: Virtualize physical hardware. Each VM runs a full guest operating system managed by a Hypervisor (Type 1 or Type 2), requiring dedicated kernel memory, slow boot times (minutes), and gigabytes of storage.
- Containers: Virtualize the operating system kernel. All containers on a host share the same underlying Linux kernel, isolated via Linux kernel primitives: Namespaces (isolating PID, network, mount, user spaces) and Cgroups (limiting CPU, RAM, and I/O resources). Containers boot in milliseconds and share host memory efficiently.
2. Images vs Containers:
- Docker Image: An immutable, read-only template built from stacked union filesystem layers (Overlay2) defined by a Dockerfile.
- Docker Container: A live, runnable instance of an image with a thin, writable top layer.
3. Benefits:
- Solves the 'works on my machine' dilemma by bundling application code, runtime, system libraries, and configuration into a portable, reproducible artifact.