Introduction to Docker
Docker is an open platform for developing, shipping, and running applications inside lightweight, portable containers. It eliminates the classic "works on my machine" problem by packaging your app and everything it needs into a single, reproducible unit.
The problem Docker solves
Before containers, deploying software meant wrestling with environment differences — the developer's laptop ran a different OS version than staging, which differed from production. Library versions drifted, configurations clashed, and deployments were risky.
Docker packages an application together with its runtime, libraries, environment variables, and configuration into a container image. That image runs identically everywhere Docker is installed: a laptop, a CI server, or a cloud VM.
Containers vs. Virtual Machines
| Virtual Machine | Docker Container | |
|---|---|---|
| Isolation | Full OS per VM | Shared host kernel |
| Size | Gigabytes | Megabytes |
| Startup | Minutes | Milliseconds |
| Overhead | High (hypervisor) | Near zero |
| Portability | VM image is large & format-specific | Same image anywhere Docker runs |
Containers are not VMs — they share the host OS kernel and are isolated using Linux namespaces and cgroups. This makes them dramatically lighter and faster to start.
Docker Engine components
Docker CLI
- docker build — build an image
- docker run — start a container
- docker push/pull — share images
Docker Daemon (dockerd)
- Manages images, containers, networks, volumes
- Listens on a UNIX socket
- Calls the container runtime
Container Runtime
- containerd manages container lifecycle
- runc creates & runs containers
- OCI-compliant
Core vocabulary
| Term | Definition |
|---|---|
| Image | A read-only, layered template. Every container starts from an image. |
| Container | A running (or stopped) instance of an image. Writable layer on top. |
| Dockerfile | A text file with instructions to build an image step by step. |
| Layer | Each Dockerfile instruction creates a cached, immutable filesystem layer. |
| Registry | A server that stores and distributes images (e.g. Docker Hub). |
| Tag | A human-readable label for a specific image version (e.g. nginx:1.27). |
| Volume | A managed storage mount that persists data beyond the container's life. |
| Network | A virtual network that connects containers to each other and the outside world. |
Installing Docker
The recommended way to install Docker on any platform is Docker Desktop (Mac, Windows) or the Docker Engine package on Linux.
# Linux — add the official Docker repo, then install
curl -fsSL https://get.docker.com | sh
# Verify installation
docker version
docker info
Your first container
# Pull and run the official hello-world image
docker run hello-world
# Run an interactive Ubuntu shell — exit to stop
docker run -it ubuntu bash
# Run nginx and publish port 80 to localhost:8080
docker run -d -p 8080:80 --name my-nginx nginx
# See what's running
docker ps
# Stop and remove
docker stop my-nginx
docker rm my-nginx
docker run nginx works: Docker checks for the image locally → not found → pulls nginx:latest from Docker Hub → creates a container layer → starts the container process.How this tutorial is organised
- Getting Started — this page, then Images & Dockerfiles.
- Core Concepts — Containers, Volumes, and Networking.
- Tooling — Docker Compose for multi-container apps, and Registries for sharing images.
- Reference — a full Docker CLI cheat sheet.