Introduction to Containerization: Docker versus Virtual Machines
Before containers, developers used Virtual Machines (VMs) to isolate application environments. While VMs are effective, they come with high resource overhead. Docker introduced a lightweight alternative called containerization.
1. Containers vs Virtual Machines
graph TD
subgraph VM [Virtual Machine Architecture]
A1[App A] --> B1[Guest OS]
B1 --> C1[Hypervisor]
C1 --> D1[Host OS / Hardware]
end
subgraph Container [Docker Container Architecture]
A2[App A] --> B2[Docker Engine]
B2 --> D2[Host OS / Hardware]
end- Virtual Machines: Each VM includes a complete guest operating system, virtual hardware, and system binaries. This makes VMs heavy (multiple gigabytes) and slow to start.
- Docker Containers: Containers share the host operating system's kernel. They do not run a guest OS, making them extremely lightweight (a few megabytes), resource-efficient, and fast to start (usually in milliseconds).
2. Docker Architecture
Docker uses a client-server architecture:
- Docker Client: The CLI utility (
docker) you use to type commands. - Docker Host (Daemon): The background service (
dockerd) running on your host machine that builds, runs, and manages containers. - Docker Registry (Docker Hub): The cloud-based database where Docker images are stored and shared.
Published on Last updated: