Docker Overview
Docker is a platform for building, shipping, and running applications in containers. A container packages your app and its dependencies into a single runnable unit that behaves the same on your laptop, CI, and production servers.
Why Containers?
Section titled “Why Containers?”- Consistency — “It works on my machine” goes away. The same image runs identically everywhere Docker runs.
- Isolation — Each container has its own filesystem, network, and process space. No dependency conflicts between apps.
- Portability — Build once, run on Linux, macOS, Windows (with WSL2), or in the cloud.
- Efficiency — Containers share the host kernel and start in seconds, unlike full VMs.
Containers vs Virtual Machines
Section titled “Containers vs Virtual Machines”| Containers (Docker) | Virtual Machines | |
|---|---|---|
| Isolation | Process-level; shares host kernel | Full machine; own kernel per VM |
| Start time | Seconds | Minutes |
| Size | MB (image layers) | GB (full OS) |
| Use case | App runtime, microservices, CI | Legacy apps, strong isolation, different OS |
Key Terminology
Section titled “Key Terminology”- Image — A read-only template (filesystem + config). Built from a Dockerfile or pulled from a registry.
- Container — A running instance of an image. You can have many containers from the same image.
- Dockerfile — A text file of instructions (FROM, RUN, COPY, etc.) used to build an image.
- Registry — A store for images (Docker Hub, Amazon ECR, Google GCR, private registries).
- Docker Compose — A tool and file format (
docker-compose.yml) to run multi-container apps with one command.
Topics in This Section
Section titled “Topics in This Section”- Installation — Install Docker Engine on Linux, Mac, or Windows (WSL2); verify with
docker run hello-world. - Dockerfile — FROM, RUN, COPY, WORKDIR, ENV, EXPOSE, CMD, ENTRYPOINT, multi-stage builds, and .dockerignore.
- Images and Registries — Building and tagging images, layers, pushing and pulling (Docker Hub, ECR, etc.).
- Running Containers —
docker runoptions (-d, -it, -p, -v, -e), lifecycle, logs, and exec. - Docker Compose — Compose file (services, networks, volumes),
docker compose up/down/ps, multi-container apps. - Volumes and Storage — Volumes vs bind mounts vs tmpfs, persistence,
docker volume. - Networking — Default networks (bridge, host, none), user-defined networks, container DNS.
- Best Practices — Small images, non-root user, health checks, security, and layer caching.