Loose parts
You build something in your workshop and it works perfectly, with your tools and your parts. Then you post the loose parts to two ships. One has different tools on board; the other is missing a part you didn't know you needed. Every ship is a surprise.
Environment drift
An application depends on much more than its code: a language runtime of a particular version, OS libraries, environment variables, config files. Install those by hand on each server and they drift: test has Java 17, production is missing a font library, a laptop has an env var nobody wrote down. Result: "works on my machine".
One standard box
So you pack the thing and everything it needs into a standard shipping container, and leave it at the container yard. Any ship can collect an identical copy, and every ship carries it the same way.
Images and containers
A Dockerfile describes how to build an image: a read-only stack of layers.
1FROM eclipse-temurin:21-jre2COPY target/app.jar /app/app.jar3EXPOSE 80804ENTRYPOINT ["java", "-jar", "/app/app.jar"]
docker build -t shop/orders:1.4 . builds it, docker push uploads it to a registry, and docker run starts a
container, a running instance. The same image runs on a laptop, in CI and in production. Layers are cached and shared,
so rebuilding after a code change only redoes the last layers.
Many boxes, one ship
A ship carries many boxes. None can see into the others, each has a weight limit, and they all share one hull, which is why they're so much lighter than sending a ship each.
Containers versus virtual machines
A container is an isolated process, not a computer. Linux namespaces give it its own filesystem, process ids and network; cgroups limit its CPU and memory. Every container shares the host's kernel, so it starts in milliseconds and uses megabytes, where a VM boots a whole OS. The trade-off is weaker isolation than a VM.
Containers are disposable: keep data in volumes or databases, not inside the container.