Cloud / DevOps Engineer · Focus area 2: Containers and orchestration
CD1: Containers done well
Goal: package an app as a small, safe container image that builds quickly, runs as an ordinary user, tells Docker when it's ready and shuts down cleanly, so the same image can run on a laptop, a test server and production without surprises.
You'll need: Module 63 (Introduction to Linux), Module 64 (Linux Commands), Module 69 (Docker), Docker installed, and the RouteRani practice kit (download it from this path's Projects page).
Where this is used: almost every modern deploy ships a container image: a food delivery app's order service, a bank's statement generator, a government portal's login page. The image is the thing that moves through testing and into production, so its quality decides how fast, safe and predictable every release is.
How it differs: an app developer writes a Dockerfile that works on their computer. A DevOps engineer makes sure the image is small, rebuilds in seconds, carries no secrets, doesn't run as root and behaves well when hundreds of copies are started and stopped every day.
Time: reading about 2 hours · practice (the Try it tasks) about 3 hours · assignment about 3 hours.
Lessons
- 1Images, containers and layersReading 15–25 minutes, plus practice✓
- 2A Dockerfile that builds small and fastReading 15–25 minutes, plus practice✓
- 3Running containers safelyReading 15–25 minutes, plus practice✓
- 4Health checks and clean shutdownsReading 15–25 minutes, plus practice✓
- 5Tags, registries and keeping images healthyReading 15–25 minutes, plus practice✓
🛠️Assignment: A production-ready RouteRani image
This is the first part of Project 1.
- Rewrite
app/Dockerfilewith a pinned slim base, two stages,npm ci --omit=dev, and layers ordered for the cache. - Add
app/.dockerignoreleaving outnode_modules,test,.env, logs and the Dockerfile itself. - Run as the
nodeuser, add aHEALTHCHECKon/ready, and start with the exec formCMD ["node", "server.js"]. - Build as
routerani:1.0.0and record the size before and after indocs/image.md. - Show a clean shutdown: stop a running container and show its log and how long
docker stoptook.
Self-check before you finish:
- [ ]
docker run --rm --entrypoint id routerani:1.0.0 -uprints a number other than 0. - [ ]
docker inspectshows a health check, and a running copy reacheshealthy. - [ ] There's no
testfolder or.envfile in the image. - [ ] Changing
server.jsand rebuilding reuses the cached dependency layer. - [ ]
npm run test:infratest 3 passes.
✅Module check
Explain in a few sentences, in your own words:
What makes a container image ready for production?
Show a good answer
A good answer mentions: a pinned, slim base image; layers ordered so dependencies are cached; a .dockerignore and multi-stage build
so only what the app needs is inside; no secrets in any layer; running as a non-root user with resource limits; a health check on a
readiness path; starting the app directly so it receives SIGTERM and shuts down cleanly; and a unique version tag per build, pushed to a
registry, scanned and rebuilt regularly.
📚Official references
Official documentation and guidance for this module's topics, chosen on 2 November 2026. Tools, laws and standards change, so check the current version before you rely on a detail. If a link has moved, search the same site.
📝Module quiz
10 questions · 10 marks each · 100 marks in all · pass mark 70% · retry as often as you like ·
