Containers vs. VMs: The Foundation
Key Takeaways for AI & Readers
- OS Virtualization: Containers share the host kernel but isolate user space, making them lighter than VMs.
- Image vs. Container: Images are read-only blueprints; containers are their live, executable instances.
- Registry: Centralized storage for images (e.g., Docker Hub) used to distribute applications.
- Runtime: The underlying engine (like containerd) that executes containers on a host.
Before diving into Kubernetes, you must understand the atom it manages: the Container.
What is a Container?
A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.
Containers vs Virtual Machines (VMs)
App ABins/Libs
App BBins/Libs
App CBins/Libs
Guest OS
Guest OS
Guest OS
Hypervisor
Host Operating System
Infrastructure (Hardware)
Each App has its own Operating System. Heavy, slow to boot, excellent isolation.
- VMs: Virtualize the hardware. Each VM has a full OS (Kernel + User Space) running on top of a Hypervisor. They are heavy and slow to boot (minutes).
- Containers: Virtualize the Operating System. All containers share the host's Linux Kernel but have their own isolated User Space (bins/libs). They are lightweight and boot instantly (milliseconds).
Key Concepts
1. Image
The blueprint. A read-only template with instructions for creating a Docker container.
- Example:
nginx:latest,node:18-alpine - Built using a
Dockerfile.
2. Container
The running instance of an image. You can have many containers running from the same image.
3. Registry
The library. A place to store and download images.
- Public: Docker Hub, Quay.io.
- Private: AWS ECR, Google Artifact Registry.
4. Runtime
The engine. The software that actually runs the containers on the host machine.
- Docker: The most famous one.
- containerd: The industry standard runtime (used by modern Kubernetes).
- CRI-O: Another lightweight runtime for K8s.
The Kubernetes Connection
Kubernetes doesn't build your source code. It doesn't even build your container images.
- You build your image.
- Push it to a Registry.
- Tell Kubernetes: "Run 3 copies of this image".