An image runs unchanged after its hosts' container stack was replaced — which two published specifications make that possible?
answer
- portability is an agreement, not magic
- two contracts, not one
- what an image is; what a runtime is handed
- any conforming builder, registry, manager, runtime
- architecture and kernel family still have to match
basics
~20 sTwo agreements carry it: an image specification fixing what an image is — content-addressed layers plus a recorded configuration of command, environment and architecture — and a runtime specification fixing what a runtime is handed and what it must do with it.
solid answer
~50 sThe artifact is portable because two separate things are written down and agreed on. The first is an **image specification**: what an image is as bytes — an ordered set of content-addressed layers, a manifest naming them by digest, and a configuration recording the default command, environment, working directory, user and target architecture. The second is a **runtime specification**: what a runtime is handed — an unpacked root filesystem plus a configuration document — and which lifecycle operations it must support on it. Between them, any conforming builder, registry, manager and low-level runtime interoperate, so a fleet can replace its whole container stack without rebuilding a single artifact. What the two do not promise is equally important: the same processor architecture and the same operating-system family are still required, and everything above the runtime — networking, storage, orchestration — is not covered by either.
go deeper
Remember that portability rests on written agreements, not on one tool: one fixes what an image is, the other fixes what a runtime is handed. Being able to name those two roles is the expected answer at this stage.
Explain the contents of each: layers, digests, manifest and default configuration on one side; the bundle and lifecycle operations on the other. Then say which components read which, and what neither one covers.
Use the limits to make a prediction: replacing a host's container stack is routine, changing architecture or kernel family is not, and changing orchestration platforms is unaffected by either specification because that layer was never standardised here.
Treat the two specifications as the reason a fleet can bet on an artifact format independently of the runtime stack it runs on today. The leverage is in keeping everything platform-specific above the runtime seam, so a stack migration never becomes a rebuild of every artifact.
"Build once, run anywhere" is not a property of images; it is the consequence of two documents that several independent implementations agreed to honour. Knowing which document covers what is how you predict, in advance, what will and will not survive a change of container stack underneath a workload. ## The image specification: what an artifact *is* The first agreement fixes the artifact itself, so that anything which can produce one can be consumed by anything that can run one. It covers: - **Layers**, as an ordered set of filesystem changesets, each identified by a **digest** computed from its own bytes. Content addressing is what makes a layer verifiable and shareable rather than merely named. - **A manifest** listing those layers by digest together with the image's configuration, so an image has one exact identity independent of any tag pointing at it. - **A configuration object** recording what should happen by default when the image runs: the command, the environment, the working directory, the user, and the processor architecture and operating-system family the image was built for. Because this is written down, the tool that built the image, the registry that stored it and the manager that pulled it need nothing in common but the format. ## The runtime specification: what a runtime is *handed* The second agreement fixes the other seam — between the component that prepares a container and the component that starts one. It covers: - **The bundle**: an unpacked root filesystem directory plus a configuration document describing the process to run, the mounts, the per-resource views, the ceilings, the user and the privilege set. - **The lifecycle operations** a runtime must implement on that bundle — create it, start it, query its state, signal it, delete it — so any manager can drive any conforming runtime. This is why a low-level runtime can be replaced on a host without the layer above being rewritten, and why a manager written by one group can drive a runtime written by another. ## What each one does and does not fix | | Image specification | Runtime specification | |---|---|---| | Fixes | What an image is, as bytes and metadata | What a runtime is handed, and what it must do | | Read by | Builders, registries, container managers | Container managers and low-level runtimes | | Identity it defines | A digest naming exact content | A bundle naming one intended container | | Does not cover | How a container is fenced or started | How images are stored or distributed | | Also does not cover | Networking, storage attachment, scheduling | Networking, storage attachment, scheduling | ## What portability still costs you The honest limits are worth saying out loud, because they are where "it runs anywhere" fails in practice: 1. **Architecture.** A single-architecture image runs on that architecture. Running elsewhere requires an image index carrying a build per architecture, or emulation with its performance cost. 2. **Operating-system family.** These containers share the host's kernel. An image built for one kernel family does not run on another, however conforming everything else is. 3. **Everything above the runtime.** How a workload gets a network address, how durable storage is attached, how replicas are placed — none of that is fixed by either specification. Platforms define those with their own interfaces, and that is exactly where moving between stacks stops being free. 4. **What the workload assumes.** An image that expects a host path, a device or a particular kernel tunable is portable as bytes and unportable in practice. ## Why this is the interesting answer in an interview The weak answer is "containers are portable because they bundle their dependencies" — true but shallow, and it does not explain why replacing a host's entire container stack leaves the artifact untouched. The strong answer names the two seams. Dependencies being bundled is what makes an image self-contained; the two specifications are what make a *different vendor's* manager and runtime able to consume that image without anyone renegotiating anything. It also predicts the failure modes correctly: a change of stack is usually uneventful, a change of architecture or kernel family is not, and a change of orchestration platform is a different project entirely, because that layer was never covered.
- Which of the two specifications is the reason a low-level runtime can be swapped on a host?The runtime specification. It fixes the bundle — an unpacked root filesystem plus a configuration document — and the lifecycle operations a runtime must support, so any conforming runtime can be dropped into that slot. The image specification is irrelevant there: the runtime never sees an image, only what the manager unpacked from it.
- If both specifications are honoured, why can moving to a different orchestration platform still be a large project?Because neither one covers the layer above the runtime. How a workload is declared, how it gets an address, how durable storage is attached and how replicas are placed are defined by each platform's own model. The artifact moves unchanged; the specs describing how to run it do not.
saying these in an interview costs you the question
- Says an image bundles its own kernel, so it runs on any host
- Thinks one vendor's tooling is what makes images portable
- Assumes a single-architecture image runs on any processor
- Believes the image specification also fixes how a workload gets a network
- Confuses the runtime specification with a registry's distribution API