Everything you need to go from zero to production-ready
A platform to build, ship, and run containerised applications. It packages code + dependencies into a portable unit that runs identically everywhere — your laptop, CI server, or cloud.
A static, read-only snapshot. Blueprint used to create containers. Layered architecture — each instruction adds a layer.
A running instance of an image. Isolated, lightweight process with its own filesystem, networking, and process space.
Storage for images. Docker Hub is the default public registry. Private registries include AWS ECR, GCR, ACR.
| Feature | Container | Virtual Machine |
|---|---|---|
| Boot time | Milliseconds | Minutes |
| Size | MBs | GBs |
| OS | Shares host kernel | Full OS per VM |
| Isolation | Process-level | Hardware-level |
| Overhead | Very low | High |
Docker Daemon (dockerd)Docker CLI (docker)REST APIEach Dockerfile instruction creates an immutable layer. Layers are cached and shared across images — huge efficiency gain.
FROM python:3.11-slimWORKDIR /appCOPY . /app or COPY requirements.txt .RUN pip install -r requirements.txtCMD ["python","app.py"]ENTRYPOINT ["gunicorn"]ENV NODE_ENV=productionARG VERSION=1.0EXPOSE 8080VOLUME ["/data"]LABEL version="1.0" maintainer="you@email.com"USER appuserHEALTHCHECK CMD curl -f http://localhost/ || exit 1-slim or -alpine base images to reduce size&& to reduce layersrequirements.txt before code — leverage layer cache.dockerignore to exclude node_modules, .git, etc.FROM python:3.11.6-slim not :latest| Driver | Description | Use case |
|---|---|---|
| bridge | Default. Creates a virtual network. Containers on same bridge talk via name. | Multi-container apps on single host |
| host | Container shares host's network namespace. No isolation. | High-performance apps, avoid port mapping |
| none | No networking. Container completely isolated. | Batch jobs, security-sensitive tasks |
| overlay | Spans multiple Docker hosts. Used with Docker Swarm. | Distributed/clustered applications |
| macvlan | Assign MAC address to container — appears as physical device. | Legacy apps expecting direct network access |
Syntax: -p host_port:container_port
Container filesystems are ephemeral — data is lost when a container is removed. Volumes persist data outside the container lifecycle.
Use for sensitive data like passwords that shouldn't be written to disk, or as a high-speed scratch space.
Tool for defining and running multi-container applications. A single docker-compose.yml file defines all services, networks, and volumes.
| Field | Purpose |
|---|---|
build | Path to Dockerfile context, or {context, dockerfile} |
image | Image name to use or tag as |
ports | Host:container port mapping |
environment | Env vars as list or map |
env_file | Load env vars from file (e.g. .env) |
volumes | Mount volumes or bind mounts |
depends_on | Start order + optional healthcheck condition |
networks | Attach service to named networks |
restart | no / always / unless-stopped / on-failure |
healthcheck | Check if service is ready |
deploy | Replicas, resource limits (Swarm/Kubernetes) |
profiles | Only start service when profile is active |
Prevents files from being sent to build context — keeps images small and fast.
| Policy | Behaviour |
|---|---|
no | Never restart (default) |
always | Always restart, even on manual stop |
unless-stopped | Restart unless explicitly stopped |
on-failure | Restart only on non-zero exit code |
Dramatically shrink production image size by discarding build tools.
USER to run as non-root inside container--read-only flag for immutable containers--no-new-privileges to block privilege escalationdocker scout cves <image>:latest in production/var/run/docker.sock) unless necessaryexport DOCKER_CONTENT_TRUST=1--cap-drop ALL --cap-add <needed>Each service in its own container — independent deployment and scaling.
Identical environments from dev → test → prod. No "it works on CI" issues.
Run Postgres, Redis, Kafka locally in seconds without installing anything.
Package models with all CUDA deps. Reproducible experiments.
Containerise legacy apps once — run on AWS, GCP, or Azure unchanged.
Spin up fresh environments per test run. Destroy after. No state leakage.