CD1: Containers done well

Lesson 1 of 5 · reading 15–25 minutes; practice and project time is on the module page

Images, containers and layers

🎯You'll be able to

Explain what an image and a container are, how they differ from a virtual machine, and read the layers of an image.

🏠The everyday picture

A tiffin service cooks one recipe and packs identical boxes. The recipe card is the image: written once, never changed. Each box sent out is a container: a running copy made from the recipe. If one box is spilled, you pack another from the same card; you don't repair the spilled one.

📘What it really is

📝A worked example

Input: in the RouteRani kit, run docker build -t routerani:latest app, then docker images routerani and docker history routerani:latest.

Expected output: one image of about 1.6 GB, and a history that starts with the many layers of the full node:22 base image, then your COPY . . and RUN npm install layers. Measured on 1 November 2026 with Docker 29.9.2 on Linux; sizes vary a little by version. You'll bring it under 250 MB in Lesson 2.

🌍Where it's used

📝Case scenario

A college's results portal ran on a server that a staff member had set up by hand years earlier. When the server's disk failed on results day, nobody could remember which Node.js version and libraries it used, and rebuilding took two days. The next year the portal shipped as an image: a new server ran it within minutes of being started.

🖱️Try it

Run docker run --rm -it routerani:latest sh, then cat /etc/os-release and node --version, and type exit. Compare with the same commands on your own computer. Success: you can say which operating system userland and Node.js version the image carries.

⚠️Common mistakes

🛠️For your project

Project 1 test 3 inspects the image you build from app/: who it runs as, whether it has a health check and what was copied in.

✅Quick check

What's the difference between an image and a container?

Show the answer

An image is the read-only recipe; a container is a running copy made from it, with a thin writable layer that's thrown away.

Why do containers start faster than virtual machines?

Show the answer

They share the host's kernel, so there's no operating system to boot.

← BackCD1
ProLearners Assist