01-What is Docker?
Understand what Docker is, why it exists, and how it solves the 'it works on my machine' problem with containerization.
The Problem Docker Solves
You’ve probably heard the classic developer complaint: “It works on my machine!” — but breaks in staging, production, or on a teammate’s laptop.
This happens because applications depend on:
- Specific OS libraries
- Runtime versions (Node 18 vs Node 20)
- Environment variables
- File paths and configs
Docker solves this by packaging your app and all its dependencies into a single portable unit called a container.
Docker vs Virtual Machines
Many people confuse Docker containers with virtual machines (VMs). Here’s the key difference:
| Feature | Virtual Machine | Docker Container |
|---|---|---|
| OS | Full OS per VM | Shares host OS kernel |
| Size | GBs | MBs |
| Startup time | Minutes | Seconds |
| Resource usage | Heavy | Lightweight |
| Portability | Limited | Excellent |
| Use case | Full OS isolation | App isolation |
Containers are not VMs. VMs virtualise hardware; containers virtualise the OS process space.
Docker Architecture
Docker uses a client–server architecture:
┌─────────────────────────────────────────────┐
│ Docker Host (your machine) │
│ │
│ ┌──────────┐ ┌──────────────────┐ │
│ │ Docker │ REST │ Docker Daemon │ │
│ │ Client │◄──────►│ (dockerd) │ │
│ │ (CLI) │ API │ │ │
│ └──────────┘ └────────┬─────────┘ │
│ │ │
│ ┌───────────────┼───────────┐ │
│ │ │ │ │
│ ┌────▼───┐ ┌───────▼──┐ ... │ │
│ │ C1 │ │ C2 │ │ │
│ └────────┘ └──────────┘ │ │
└─────────────────────────────────────────────┘
▲
│ docker pull / push
▼
┌──────────────┐
│ Docker Hub │
│ (Registry) │
└──────────────┘
Three main components:
- Docker Client — the
dockerCLI you type commands into - Docker Daemon (
dockerd) — the background service that does the actual work - Docker Registry — stores Docker images (Docker Hub is the default public registry)
Installing Docker
macOS / Windows
Download Docker Desktop from docker.com — it includes Docker Engine, CLI, and Docker Compose.
Ubuntu / Debian
# Remove old versions
sudo apt-get remove docker docker-engine docker.io containerd runc
# Install prerequisites
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
# Add Docker's official GPG key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# Set up the repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker Engine
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Add your user to the docker group (no more sudo)
sudo usermod -aG docker $USER
newgrp docker
Verify Installation
docker --version
# Docker version 26.1.0, build a0fcdb4
docker run hello-world
# Pulls the hello-world image and runs it
You should see: “Hello from Docker!”
docker run hello-world after every fresh install to confirm Docker can pull from Docker Hub and run containers.Core Vocabulary
| Term | What it means |
|---|---|
| Image | Read-only blueprint for a container (like a class in OOP) |
| Container | A running instance of an image (like an object) |
| Dockerfile | Instructions to build a custom image |
| Registry | Storage for images (Docker Hub, ECR, GCR) |
| Volume | Persistent storage that survives container restarts |
| Network | Virtual network connecting containers |
Summary
- Docker packages apps + dependencies into containers
- Containers are lightweight (share host OS kernel) unlike VMs
- Docker uses a client–server architecture (CLI → daemon)
- Images are blueprints; containers are running instances
You’re ready to start building your first container in the next lesson!