PREP WITH PROOF
Menu
DOCKER & DEVOPS / PRACTICAL GUIDE

Docker Image Tags vs Digests: Pin the Right Multi-Platform Object

Pin Docker images correctly: distinguish tags, index digests, platform manifest digests and local IDs, inspect registry references, and run a 60-check offline lab.

THE QUICK ANSWER

A Docker tag names a reference that a publisher can move. A digest identifies exact content. For a multi-platform image, the top-level digest can identify an index containing several platform manifests, so two machines can use the same pinned index while selecting different platform images. Record the repository, digest, object type and target platform together; do not substitute a local image ID for a registry manifest digest.

Why the same release tag can produce different deployments

Imagine a service that passed staging yesterday with an image called registry.example.com/team/api:release. A publisher replaces that tag before production pulls it. Both deployment files still say release, yet the two environments may have resolved different content. This is an illustrative failure scenario, not a report of an observed outage.

A version-shaped tag such as 2.4.1 is more descriptive than latest, but its spelling does not enforce immutability. A registry can offer policies that prevent replacement; that is a separate control to verify. For a release record, retain the approved content digest rather than assuming a naming convention provides that guarantee.

Pinning solves the reference-selection part of the problem. It does not freeze configuration, mounted data, remote APIs or the host kernel. Before investigating why two deployments behave differently, separate image identity from the environment in which the containers run.

Source: Docker: pull images by tag or digest ↗

Read the object type before comparing hashes

The prefix sha256 tells you the hash algorithm, not what object was hashed. Several different objects in an image graph can have SHA-256 digests. A long hexadecimal value alone is therefore an incomplete incident record. Start by asking which registry repository and which object the value belongs to.

An OCI index links to child manifests through descriptors. Each descriptor carries a media type, byte size and digest; a platform descriptor can also describe the intended operating system and architecture. A child manifest in turn references configuration and layer content. The top-level object is not a concatenation of every file in the running container.

Reference or valueWhat it identifiesHow to use it
repository:tagA named reference that can be reassignedConvenient discovery; resolve and review before promotion
repository@sha256:… (index)Exact index bytes referencing child manifestsPin a multi-platform release set; also record the selected platform
repository@sha256:… (manifest)Exact manifest bytes referencing configuration and layersPin a specific image manifest after reviewing its platform
Local image IDImplementation-dependent local image identityLocal diagnostics; do not assume it is a registry pull digest
Layer digest or DiffIDA layer representation or uncompressed layer archiveLayer analysis; not a replacement for the image reference

Source: OCI: content descriptors and byte digests ↗

One pinned index can legitimately select different platform images

A release may contain both linux/amd64 and linux/arm64 manifests. Pinning its index freezes the list of referenced objects. Platform selection still determines which child image is used. Different child digests on an x86 server and an ARM server can therefore be expected, even when both deployments share the same index digest.

Use an index pin when the deployment should select from an approved multi-platform release. Use a child manifest pin when the reviewed artifact is deliberately platform-specific. Neither choice makes an amd64 executable native to arm64; compatibility or emulation remains a separate runtime concern.

For auditability, record the index digest, selected child digest and platform when those distinctions matter. Do not choose the first descriptor merely because it appears first in a JSON array. Inspect media types and platform fields: real indexes can include additional metadata objects or nested indexes, beyond the two uncomplicated image descriptors in our lab.

Source: OCI: image index and platform descriptors ↗

Resolve once, then inspect the pinned reference

The following Bash workflow requires Docker with the Buildx plugin and registry access. It is a documented command pattern, not an executed registry test in this guide: Docker is unavailable in our verification environment. Replace the example repository and tag with a destination you control or trust. No sample hexadecimal digest below is presented as a current public image.

First inspect the tagged reference and review the top-level Digest and MediaType. Copy that complete digest into DIGEST. Re-inspect repository@digest before approval, and review the child platform descriptors if the object is an index. This second inspection uses the selected content identity even if the tag moves between commands.

# Replace with a real repository and tag before running.
REPO='registry.example.com/team/api'
TAG='release'
docker buildx imagetools inspect "$REPO:$TAG"

# Copy the complete reviewed top-level digest from the output.
read -r -p 'Reviewed digest (sha256:...): ' DIGEST
[[ "$DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]] || exit 1
PINNED="$REPO@$DIGEST"
docker buildx imagetools inspect "$PINNED"
docker buildx imagetools inspect --raw "$PINNED"

# Choose a platform actually present in the reviewed index.
docker image pull --platform linux/amd64 "$PINNED"

Source: Docker: inspect registry images with Buildx ↗

Keep a reviewable deployment reference

After the inspection, store the full repository@digest reference in the deployment configuration or release artifact, with the target platform alongside it. For a Dockerfile base image, FROM accepts a digest reference. A readable tag can accompany the digest, but treat the digest as the content selection; do not infer that a human-readable tag still describes its current registry mapping.

An application image pin and a base image pin answer different questions. The application pin identifies what you deploy. The base pin controls one input to a later build. Rebuilding the same Dockerfile can still change output when package repositories, dependency resolution, timestamps or downloaded artifacts change. Pinning a base alone is not proof of a reproducible build.

Likewise, hashing a docker save archive or a pretty-printed manifest file does not automatically yield the registry manifest digest. Archive packaging and JSON serialization have their own bytes. When comparing a claimed digest, obtain the exact referenced content and understand the tool output rather than treating every representation as interchangeable.

Source: Docker: pin base image versions and review updates ↗

An offline lab: exact bytes, parent identity and child identity

Save this complete standard-library Python program as digest_lab.py and run python digest_lab.py without optimization flags. We executed the exact program and obtained 60 passing checks. It constructs two empty-filesystem configuration objects, two child manifests and an OCI-style index entirely in memory. These are invented metadata fixtures, not published images or runnable applications.

The checks show that the index, two manifests and two configurations have five distinct digests; that descriptors match the original bytes; and that changing whitespace preserves parsed JSON while changing its digest. Adding an annotation changes the parent index identity without changing either child descriptor. A tiny dictionary models tag reassignment while retaining access to the original digest.

The corruption loop changes individual bytes without changing content length. Digest verification still rejects each modified byte sequence, while a separate check rejects a wrong size. This is a focused content-addressing demonstration, not a complete OCI validator, registry client, signature verifier or Docker platform-selection implementation.

import copy
import hashlib
import json

checks = 0

def check(condition):
    global checks
    assert condition
    checks += 1

def encode(value):
    return json.dumps(value, sort_keys=True, separators=(',', ':')).encode()

def digest(data):
    return 'sha256:' + hashlib.sha256(data).hexdigest()

def descriptor(data, media_type):
    return {'mediaType': media_type, 'digest': digest(data), 'size': len(data)}

def matches(data, desc):
    return len(data) == desc['size'] and digest(data) == desc['digest']

prefix = 'application/vnd.oci.image.'
manifest_type = prefix + 'manifest.v1+json'
config_type = prefix + 'config.v1+json'
index_type = prefix + 'index.v1+json'
configs, manifests, children = {}, {}, []
for arch in ('amd64', 'arm64'):
    # Empty filesystem: metadata fixture, no executable application.
    configs[arch] = encode({'architecture': arch, 'os': 'linux',
                            'rootfs': {'type': 'layers', 'diff_ids': []}})
    manifests[arch] = encode({'schemaVersion': 2, 'mediaType': manifest_type,
        'config': descriptor(configs[arch], config_type), 'layers': []})
    child = descriptor(manifests[arch], manifest_type)
    child['platform'] = {'os': 'linux', 'architecture': arch}
    children.append(child)
index = {'schemaVersion': 2, 'mediaType': index_type, 'manifests': children}
raw = encode(index)
index_desc = descriptor(raw, index_type)
check(matches(raw, index_desc))
check(len({digest(raw), *map(digest, manifests.values()),
           *map(digest, configs.values())}) == 5)
for child in children:
    arch = child['platform']['architecture']
    check(matches(manifests[arch], child))
    config_desc = json.loads(manifests[arch])['config']
    check(matches(configs[arch], config_desc))
    check(digest(raw) != child['digest'])
    check(config_desc['digest'] != child['digest'])
# Same parsed JSON, different exact bytes.
pretty = json.dumps(index, indent=2, sort_keys=True).encode()
check(json.loads(pretty) == json.loads(raw))
check(digest(pretty) != digest(raw))
check(not matches(pretty, index_desc))
# Change the parent only: existing children keep their identities.
annotated = copy.deepcopy(index)
annotated['annotations'] = {'example.test/note': 'reviewed'}
check(digest(encode(annotated)) != digest(raw))
check(annotated['manifests'] == index['manifests'])
# A moving tag is a lookup table here, not a registry operation.
by_digest = {digest(raw): raw, digest(encode(annotated)): encode(annotated)}
tags = {'release': digest(raw)}
old = tags['release']
tags['release'] = digest(encode(annotated))
check(tags['release'] != old)
check(by_digest[old] == raw)
# In-place byte corruption keeps size but fails digest verification.
for position in range(0, len(raw), max(1, len(raw) // 20)):
    corrupt = bytearray(raw)
    corrupt[position] ^= 1
    check(len(corrupt) == index_desc['size'])
    check(not matches(bytes(corrupt), index_desc))
wrong_size = dict(index_desc, size=index_desc['size'] + 1)
check(not matches(raw, wrong_size))
print(f'PASS: {checks} checks; local metadata only, no registry or runtime')
print('index:', digest(raw))
for child in children:
    print(child['platform']['architecture'] + ':', child['digest'])

Source: OCI: content descriptors and byte digests ↗

Why the local image ID may not match the pull digest

A local image listing and a registry inspection can describe different levels of the image graph. Historically, an image ID was described as the hash of configuration JSON. The current OCI configuration specification explicitly notes implementation divergence and no longer defines one universal ImageID construction. Avoid writing release logic that depends on every engine exposing an identical kind of local ID.

Our fixture computes a configuration digest directly, so its meaning is unambiguous. It does not assert that a particular Docker version would display that value in a particular field. When investigating a mismatch, label each value by its source: registry index, child manifest, configuration descriptor or local diagnostic output. Compare like with like before concluding that content changed.

Source: OCI: image configuration and ImageID limitations ↗

Troubleshoot the failure at the correct boundary

A manifest unknown or not-found response can mean the digest is absent from that repository, removed by retention, or inaccessible under the current credentials. A digest is not a global download URL. Confirm the full registry/repository path and permissions, then inspect the exact pinned reference. Preserve approved artifacts through an appropriate retention policy; immutability does not guarantee continued availability.

For a no-matching-platform error, inspect the index descriptors and the platform requested by the deployment. A correct digest can still identify an unsuitable platform set. For an executable-format failure after pulling a child directly, check architecture compatibility before editing the digest or repeatedly pulling the tag.

If the same apparent image behaves differently, compare selected child identity, entrypoint arguments, environment, mounts and external dependencies. If a digest comparison fails after formatting JSON, return to the original bytes. The offline lab demonstrates why reconstructing equivalent JSON is insufficient for that comparison.

Make updates deliberate rather than permanent freezes

A pinned image will not silently acquire a publisher’s later fixes. Assign an owner and cadence for resolving newer candidates, reviewing their provenance and scan results, testing the chosen platforms, and replacing the approved digest through the normal release process. Keep the previous reference for rollback together with a record of configuration changes.

A digest establishes content identity; it does not establish who published it, whether its software is safe, or whether it meets your policy. Apply your existing signature, provenance and vulnerability controls separately. The useful outcome is a traceable promotion decision: which repository, which exact object, which platform, which tests and which approval.

Tags remain useful for discovering releases and communicating intent. Digests make the selected content explicit. Recording the object type and platform closes the gap between those two jobs and gives the next operator enough evidence to reproduce the selection.

Source: Docker: pin base image versions and review updates ↗

KEEP THESE THREE THINGS

Your next steps

  1. Resolve a tag to a reviewed repository@digest reference before promotion.
  2. Distinguish a multi-platform index from its child image manifests.
  3. Record the target platform and compare hashes of the same object type.
  4. Treat local image IDs and reserialized JSON as separate representations.
  5. Plan digest updates, retention and provenance checks alongside pinning.

Sources & official resources

Linked resources checked on 2026-11-02. Technical behavior and provider guidance can change; check the documentation for the version you use.

About this guide and its recommendations

Published by Prep With Proof with AI-assisted drafting. Study routines and examples are editorial suggestions, not official exam instructions or claims of a learner's personal results. Cited provider facts are linked; ownership of recommended Prep With Proof products is disclosed. No competitor endorsement or guaranteed certification outcome is implied.

Suggest a correction →