Platform & DevOps·topic 1 of 9
Packaging: containers and images
A container is a much smaller idea than it looks: a normal process, lied to about what it can see. These are the words for the artefact you build, the layers it is made of and the kernel features that make the isolation real.
Read in order · tick what you already know
- 01
the process thinks it has its own machine, and on the host it is one ordinary PID among hundreds.
Container
- 02
you ship a tarball of a whole filesystem plus a line saying what to run, and the same bytes go to every environment.
Container image
- 03
changing one line at the top of the build file invalidates every layer beneath it and the build goes from nine seconds to four minutes.
Image layer
- 04
the build was instant on your laptop and takes six minutes on the runner, because the runner starts empty every time.
Build cache
- 05
a vulnerability was reported in a library you have never imported, because it came in the operating system underneath your code.
Base image
- 06
the compiler, the test framework and the whole toolchain are used in the build and then thrown away, and the shipped image contains one binary.
Multi-stage build
- 07
you shell into the container to debug it and there is no shell, because the image contains your binary and its libraries and nothing else.
Distroless image
- 08
the container starts a shell that starts your process, so signals stop at the shell and nothing ever shuts down cleanly.
Entrypoint
- 09
the shutdown signal is delivered and ignored, and every rollout takes exactly thirty seconds per pod before something kills it.
PID 1 problem
- 10
two nodes ran what the manifest called the same version and behaved differently, because someone had pushed over the tag.
Image tag
- 11
the deployment names a sha256 hash instead of a version, and there is exactly one set of bytes that could ever satisfy it.
Image digest
- 12
the deploy failed at three in the morning because the place you pull images from was rate-limiting you, and it is not your infrastructure.
Container registry
- 13
you pushed a fix under the same tag, restarted the workload, and the node kept running the copy it already had.
Image pull policy
- 14
something on the node unpacks the image, sets up the namespaces and cgroups, and starts the process — and it is not the orchestrator.
Container runtime
- 15
an image built by one tool runs under a different runtime on someone else's cluster, and nobody had to agree on a vendor.
Open Container Initiative
- 16
the container sees PID 1, its own network interfaces and its own mount tree, all of which are a partial view of the host's.
Linux namespaces
- 17
the process is capped at half a CPU and a gigabyte by the kernel, and it has no idea — it still reports the host's numbers.
cgroups
- 18
the container writes a file and it lands in a thin writable layer on top, leaving the image underneath untouched.
Overlay filesystem
- 19
the uploaded files were there all afternoon and gone after a restart, because they were written inside the container.
Ephemeral container filesystem
- 20
configuration comes from the environment, logs go to stdout, and the same image runs in staging and production unchanged.
Twelve-factor app
- 21
the process inside is uid 1000 rather than root, so a container escape lands the attacker as nobody in particular.
Rootless container
- 22
someone added one flag to make a mount work, and that container can now reconfigure the host.
Privileged container
- 23
the attacker got out of the container onto the node, and from the node to every other tenant's workload on it.
Container escape
- 24
the pipeline compares every package in the image against a vulnerability feed and fails the build on anything critical.
Image scanning
- 25
a vulnerability was announced on a Friday and you answered 'are we affected' from a file rather than from a week of grepping.
Software bill of materials
- 26
you build the same commit twice on different machines and get byte-identical output, timestamps and all.
Reproducible build
- 27
the build runs with the network switched off, so anything it needs had to be declared up front.
Hermetic build