Sub topic 3
Anatomy of an image manifest
This chapter assumes you can build, tag, and push images, and that you can read a simple Dockerfile. It also assumes you know that x86-64 and ARM are different CPU architectures. The previous chapters covered platforms and why single-architecture images fail. This chapter looks at the file a registry serves when you ask for one image on one platform.
What a manifest is
An image manifest is a small JSON document. It does not hold any files from the image. It lists the pieces that make up the image and says where to find each one.
A manifest points to two kinds of content:
- One config blob. This is a JSON document with image metadata. It records the architecture and OS, the default command, environment variables, exposed ports, and the build history. It also lists the
diff_ids, which are the hashes of the uncompressed layers. - An ordered list of layers. Each layer is a compressed tarball holding filesystem changes. The runtime applies them from first to last to build the root filesystem.
Every pointer is a descriptor with three fields: mediaType, digest, and size. The digest is a hash of the content it points to, so the registry can serve each blob by its hash. The next chapter covers digests in detail.
A manifest in practice
This is an illustrative OCI image manifest. The digests and sizes are placeholders.
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"config": {
"mediaType": "application/vnd.oci.image.config.v1+json",
"digest": "sha256:<config-digest>",
"size": 1470
},
"layers": [
{
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
"digest": "sha256:<base-layer-digest>",
"size": 3400000
},
{
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
"digest": "sha256:<app-layer-digest>",
"size": 8200000
}
]
}The manifest has no platform field. The platform is recorded in the config blob, as architecture and os. When an image index lists this manifest, the index entry repeats the platform so a client can choose without downloading the config first.
Docker and OCI formats
Two formats are common. The OCI format uses application/vnd.oci.image.manifest.v1+json. The older Docker format uses application/vnd.docker.distribution.manifest.v2+json. The structure is nearly the same. Only the media type strings differ. Current Docker tooling and most registries accept both.
A client reads the mediaType before it parses a document. The same tag can return either a single manifest or an index, and the media type tells the client which one it received.
Why the manifest matters for multi-platform images
The layers and config in a manifest were produced for one platform. An arm64 manifest and an amd64 manifest for the same app have different config blobs and usually different layers. They have different digests, so they are separate manifests.
That is why one tag needs an extra level of indirection. A tag cannot point at two manifests directly. It points at an index, and the index points at one manifest per platform.
Common mistakes
- Treating the tag as the image. A tag is a movable name. The manifest, identified by its digest, is the fixed content.
- Looking for the architecture in the manifest. It is in the config blob, and in the index entry when an index is involved.
- Assuming one layer list fits all platforms. Each platform has its own manifest with its own layers.
Exercise
A manifest for an image has a config descriptor and three layer descriptors. Which of those documents tells you the image's architecture, and which fields does every descriptor contain?
Show answer
The config blob holds the architecture and OS. Every descriptor contains mediaType, digest, and size.