Diagramium
📦 Narrated diagram

Containers and Docker, explained

From a twenty line recipe to an identical process running on any machine on earth — images, layers, registries, isolation, and the end of works on my machine.

15 steps3 min readNarrated with a studio voice
Containers and Docker, explainedyou write the recipelayer zeroone per instructionpush oncepull anywhererunmountedexposedthe same bytesA browser or desktop client🖥️Developer laptopBlob / object storage such as S3🪣The DockerfileBlob / object storage such as S3🪣Base imageA background worker or scheduled job🛠️Docker buildBlob / object storage such as S3🪣Read only layersBlob / object storage such as S3🪣The finished imageA microservice or backend service⚙️Tag and digestA third-party or external systemImage registryA background worker or scheduled job🛠️Server pulls the imageA microservice or backend service⚙️A running containerA microservice or backend service⚙️Namespaces and limitsA microservice or backend service⚙️One shared kernelBlob / object storage such as S3🪣Volumes for real dataA microservice or backend service⚙️Published portsA browser or desktop client🖥️Every machine identical
Containers and Docker, explained — the complete diagram. Press Present to watch it build itself.
Containers and Docker, explained — Developer laptop
Step 1 of 15

Developer laptop

It starts with the oldest excuse in software: it works on my machine. Your laptop has a particular Python, a particular library and one environment variable you set six months ago and forgot. Containers exist to end that sentence for good.

Containers and Docker, explained — The Dockerfile
Step 2 of 15

The Dockerfile

A Dockerfile is a plain text recipe, often under twenty lines. Start from this base, copy these files, install these packages, run this command. Anyone who reads it can rebuild your exact environment, and that reproducibility is the real trick here.

Containers and Docker, explained — Base image
Step 3 of 15

Base image

The bottom layer is somebody else's finished work: a stripped down Linux like Alpine, under ten megabytes unpacked, or a full Ubuntu around eighty. You are not shipping a whole computer, only the small userland your program needs, because the kernel underneath is already there.

Containers and Docker, explained — Docker build
Step 4 of 15

Docker build

The build command runs your recipe one instruction at a time, and every step that touches the filesystem becomes a new cached layer. Change the last line and the rebuild takes seconds. Change the first line and every layer below it is thrown away and built again.

Containers and Docker, explained — Read only layers
Step 5 of 15

Read only layers

Layers stack like transparencies and every one of them is read only. Ten images built on the same base store that base exactly once on disk, which is why your second pull from a registry is usually far faster than your first.

Containers and Docker, explained — The finished image
Step 6 of 15

The finished image

The image is that finished stack, frozen. It is not running and it never changes: same files, same versions, forever. Think of it as a photograph of a working machine rather than the machine itself, which is why it travels so well.

Containers and Docker, explained — Tag and digest
Step 7 of 15

Tag and digest

Every image gets a human tag and a machine fingerprint. Tags can move, so the word latest is a lie waiting to happen, but the digest is a long hash that points at exactly one set of bytes and can never point anywhere else.

Containers and Docker, explained — Image registry
Step 8 of 15

Image registry

A registry is a warehouse for images. You push once and any machine on earth pulls the identical bytes. Docker Hub alone serves billions of pulls a month, and most companies also run a private registry for their own code.

Containers and Docker, explained — Server pulls the image
Step 9 of 15

Server pulls the image

The server downloads only the layers it does not already have. If it is already running three services built on the same base, the new one might be a fifteen megabyte download instead of four hundred, which is why deploys got fast.

Containers and Docker, explained — A running container
Step 10 of 15

A running container

Run the image and you get a container: a live process started from that frozen photograph. It launches in tens of milliseconds because nothing is booting. It is just your program, started with a very carefully arranged view of the world.

Containers and Docker, explained — Namespaces and limits
Step 11 of 15

Namespaces and limits

That view comes from two Linux features. Namespaces give the process its own private list of processes, its own network and its own filesystem root. Control groups cap how much memory and processor time it is allowed to take.

Containers and Docker, explained — One shared kernel
Step 12 of 15

One shared kernel

Here is the difference from a virtual machine. A virtual machine carries an entire guest operating system, gigabytes of it, and boots for half a minute. Containers share the host kernel and start in a moment, but the walls between them are drawn by that one kernel rather than by virtual hardware, which is a thinner boundary.

Containers and Docker, explained — Volumes for real data
Step 13 of 15

Volumes for real data

Containers are meant to be disposable, and anything written inside one vanishes when it stops. Real data lives in a volume mounted from outside, which is why a database in a container needs more thought than a stateless web app does.

Containers and Docker, explained — Published ports
Step 14 of 15

Published ports

By default nothing inside is reachable. You explicitly publish a port, mapping one on the host to one in the container, and Docker wires the traffic through. Two containers can both listen on port eighty and never once collide.

Containers and Docker, explained — Every machine identical
Step 15 of 15

Every machine identical

So the same image runs on your laptop, in the test pipeline and in production, byte for byte identical. The excuse dies, and the unit you hand to other people stops being a page of setup instructions and becomes an actual thing.

Watch it explain itself

Every step above is narrated aloud. Play it, or open it in the editor and make it yours — no account needed.