Docker & deployment basics
Containerize your service, health/readiness endpoints, config via environment, zero-downtime restarts, migrations that roll forward safely.
The mental model
Shipping a backend service is the difference between "it works on my machine" and "it works on every machine, survives a restart, and can be updated without anyone noticing". A container is the answer to the first half: it packages your code with its exact runtime, libraries, and OS-level dependencies into one immutable image, so the thing you tested is byte-for-byte the thing that runs in production. The old class of bug — "works locally, breaks in prod because prod has a different Python" — simply cannot happen when the Python is inside the image.
The analogy that sticks: a container is a shipping container. Before standardized containers, cargo was loaded piece by piece and every ship, truck, and crane handled it differently. The steel box changed everything — the *contents* vary wildly, but the *box* is a standard size every crane can lift and every ship can stack. Your service's contents (Node, Go, Python) vary, but the container image is a standard unit any orchestrator can run, stop, replicate, and move. A VM by contrast ships the whole ship with the cargo — a full guest OS per app — which is why containers (sharing the host kernel) are seconds to start and megabytes in size while VMs are minutes and gigabytes.
The rest of deployment is about the *transitions*: how do you replace version 1 with version 2 while users are mid-request? That is where health checks, zero-downtime rollouts, and safe migrations come in. The reason these exist: a naive deploy — stop the old, start the new — drops every in-flight request and returns errors until the new version is ready. Users see a blip on every deploy, so teams deploy rarely, so each deploy is huge and risky, so deploys get scarier — a doom loop. Zero-downtime deployment breaks it: if a deploy is invisible, you deploy often, each change is small, and a bad one is trivial to roll back. This is the operational foundation the whole "deploy on Friday afternoon without fear" culture rests on.
The one idea that trips people up and is worth stating early: config comes from the environment, not the image. The same image runs in dev, staging, and prod; what differs is injected at runtime. Non-secret config (database URL, feature flags) goes in environment variables; secrets are injected from a secrets manager, ideally as mounted files. Baking config into the image means rebuilding to change a setting and, worse, baking a prod secret into a shareable artifact.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision