What is Docker?
From 'it works on my machine' to running anywhere — the why behind containers
Skills taught: docker.containers, docker.images, docker.why-docker
The problem Docker solves
Picture this: a developer builds an app on macOS, tests it, ships it — and it crashes on the Linux production server because of a different Node.js version, missing system library, or incompatible Python package. This 'works on my machine' problem is older than Docker. Docker solves it by packaging the application together with everything it needs to run — the runtime, libraries, config, and code — into a single portable unit called a container.
VMs vs Containers — a crucial distinction
- Virtual Machine (VM)
- Emulates a complete computer — CPU, RAM, disk, and a full OS kernel. Heavy (gigabytes), slow to start (minutes), but fully isolated. Used for running different operating systems on one host.
- Container
- Shares the host OS kernel but isolates processes using Linux namespaces and cgroups. Lightweight (megabytes), starts in milliseconds, and portable. Used for packaging and running applications.
Images vs Containers
These two words are used constantly and it's critical to keep them straight. An image is a blueprint — a read-only, layered snapshot of a filesystem. A container is a running instance of an image — a live process with its own isolated environment. The analogy is exact: image is to container as class is to object in programming, or recipe is to meal in cooking.
# An IMAGE is a static blueprint (read-only)
docker images
# REPOSITORY TAG IMAGE ID SIZE
# nginx latest 904b8cb13b93 187MB
# node 20-alpine 1d46ed2a75d7 55MB
# A CONTAINER is a running instance of an image
docker ps
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
# a3f2c1d4e5b6 nginx "/docker-entrypoint…" 3s ago Up 2s 80/tcp
# You can run MANY containers from ONE image
docker run -d nginx # container 1
docker run -d nginx # container 2 (same image, different container)
docker run -d nginx # container 3
Tip: Mental model: Images live in a registry (like Docker Hub) — they are downloaded once and cached locally. Containers are ephemeral — they start, run, and can be deleted. Always treat containers as throwaway; put anything you need to keep in a volume.
How Docker actually works
Docker uses three Linux kernel features to create containers: namespaces isolate what a process can see (its own filesystem, network, users, process IDs); cgroups (control groups) limit what resources a process can use (CPU, RAM, disk I/O); and a union filesystem layers image layers on top of each other efficiently. You don't need to understand all of this to use Docker — but knowing it exists explains why containers are so lightweight.
Frequently Asked Questions
Does Docker work on Windows and macOS?
Yes — Docker Desktop runs on both. Since containers use the Linux kernel, Docker Desktop runs a lightweight Linux VM invisibly on Mac and Windows to host containers. Your containers still behave identically to production Linux. On Linux, Docker runs natively without a VM.
Is Docker the only container technology?
No — containerd (which Docker itself uses internally), Podman (rootless, daemonless), and LXC/LXD also create containers. But Docker has the largest ecosystem, best tooling, and is what 90%+ of tutorials, courses, and job descriptions reference. Learn Docker first.