A complete, hands-on guide to Docker. Every section is a standalone reference you can return to anytime.
| # | Topic | What You'll Learn |
|---|---|---|
| 1 | Docker Fundamentals | Architecture, Engine, Lifecycle, Registry |
| 2 | Writing Dockerfiles | Instructions, best practices, layering |
| 3 | Multistage Builds & Distroless | Slim images, build optimization |
| 4 | Networking | Bridge, host, custom networks, DNS |
| 5 | Storage — Bind Mounts & Volumes | Persistence, data sharing |
| 6 | Real-World Deployment on EC2 | Django app, EC2 setup, public access |
# Run a container
docker run -d -p 8080:80 --name my-nginx nginx
# See running containers
docker ps
# See all containers (including stopped)
docker ps -a
# View logs
docker logs my-nginx
# Shell into a running container
docker exec -it my-nginx bash
# Build an image
docker build -t myapp:latest .
# Stop and remove a container
docker stop my-nginx
docker rm my-nginx
# List images
docker images
# Remove an image
docker rmi myapp:latestImages vs Containers — an image is a blueprint (like a class), a container is a running instance (like an object).
Layers — every Dockerfile instruction adds a layer. Layers are cached. Put things that change least (dependencies) before things that change most (your code).
The Daemon — dockerd runs in the background doing all the work. The docker CLI just sends it instructions.
docs/cheatsheet.md— all commands in one place