6.1Real-world cases
The essentials in 30 seconds
- Assemble: clean Dockerfile (slim, dependencies first, non-root), image tagged 1.0, declarative Compose stack, proven persistence, CI as the only factory.
- Prove: test locally, have a third party pull and run it, prove down/up with no loss — what is not proven does not exist.
- Share: a versioned image and a cloned repo + up = a complete app, with no "install Node 20".
Idir's thread — two deliveries in Algiers
Idir, junior DevOps in Algiers, looks back at his two landmark projects of the quarter: containerising the Node API that only ran on its author's laptop (Dockerfile, 1.0 build, hardening, push to the registry, handover to a colleague), then equipping his small team with an api + database + console Compose stack (settings, restart and healthcheck, validation, no-loss proof). Both cases below follow his sequence: write clean, build, harden, share, declare, prove.
Each case follows the Context → Steps → Result flow: replay it on your app.
Putting the building blocks end to end
The previous levels laid the building blocks (images, containers, volumes, networks, Dockerfile, Compose, registries, CI); here we assemble them under real conditions: it is the chaining of the right reflexes — hardened image, declarative stack, proven persistence, single CI — that separates a reliable deployment from a fragile pile. Two cases covered from A to Z.
Case 1 — Containerising an API from A to Z
Context: You receive a Node API that only runs on its author's laptop and you must deliver it as a shared image. Risk: a non-reproducible environment and endless "works on my machine".
Déroulé :
- Write the Dockerfile (node:20-slim, WORKDIR, dependencies first, USER node, CMD) with .dockerignore (N2.1, N2.5).
- Build as mon-app:1.0 and test locally with -p 3000:3000 (N1.2, N2.1).
- Harden: .dockerignore, non-root, scan, immutable 1.0 tag (N2.5, N4.1).
- Push to the registry and have a colleague pull + run it (N2.3, N4.1).
- Validate: a third party runs the image with one command, without installing Node 20.
Result: A shared 1.0 image, runnable anywhere with one command, with no "install Node 20".
Case 2 — Compose stack for a small team
Context: A team wants to run api + database + console with one command, with persisted data and simple updates. Challenge: a stack that breaks on the first restart.
Déroulé :
- Write compose.yml: api (build), bdd (pgdata volume), adminer in dev profile (N3.1, N3.4).
- Parameterise via ${PORT:-3000} and a versioned .env.example, .env not committed (N3.4, N2.4).
- Add restart + bdd healthcheck + depends_on healthy (N4.2, N3.2).
- Validate with config, up -d --build, then prove down/up with no loss (N3.2, N4.4).
- Document: the "how to run it" doc fits on one line (clone + up).
Result: A cloned repo + up = a complete app; the "how to run it" doc fits on one line.
Ready-to-say script — framing a Docker delivery (30 s)
"Our need: [API to share / api + database stack]. Our image: [slim, non-root, 1.0 tag, scanned]. Our stack: [versioned compose, ${PORT:-3000}, pgdata volume]. Our proof: [pull by a third party / down-up with no loss]."
Copy-paste template — real-case sequence
docker build -t mon-app:1.0 .
docker run -d --name api -p 3000:3000 mon-app:1.0
docker compose config
docker compose up -d --build
docker compose ps
docker compose down
docker compose up -d
Small business / tight budget
One small replayed case is enough: one 1.0 image, a two-service compose, a noted down/up proof.
SME in Algiers
Adapt to local realities: test on the team's real machine, plan for a backed-up pgdata volume.
Remote / hybrid
Double remote traceability: tag, registry and down/up proof noted and shared.
Intercultural
Spell out the docs before transposing a case: a "clone + up" line must speak to every newcomer.
48h challenge — apply tomorrow
Take 1 real app and replay the sequence: clean Dockerfile, 1.0 build, local run, compose validated by config, down/up with no loss proof.
- I can chain Dockerfile, build, sharing and a Compose stack on a real case.
- I have a replayable sequence (1.0 image, versioned compose, no-loss proof).
- I did the 48h challenge or scheduled its date.
Idir is delivering his API. Which sequence follows the guide?