Image names: repositories, tags and digests
How Docker reads a name like nginx:1.31 or ghcr.io/acme/api@sha256:…, which registry it really means, and when to pin a tag, a digest or both.
Image names: repositories, tags and digests
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- A full reference is registry/namespace/repository:tag@digest. Docker fills in what you leave out: docker.io for the registry, library/ for official images, and latest for the tag.
- The first part of a name counts as a registry only if it contains a dot or a colon or is localhost. Otherwise myregistry/api means a user called myregistry on Docker Hub.
- A tag is a movable label of up to 128 characters. Many tags can point at one image, and pushing a tag again silently moves it.
- A digest is the SHA-256 of a manifest or index. It can only ever name those exact bytes, so pulling by digest is repeatable.
- If a reference has both a tag and a digest, the digest decides what you get and the tag is only a note for humans.
- latest is just the default tag name. It means whatever was last pushed under that name, not the newest version.
Two words, five decisions
docker run nginx looks like one word. Docker reads it as five decisions: which registry, which namespace, which repository, which tag and which exact bytes. When you don’t say, it fills in defaults. Most of the time that’s convenient. Sometimes it pulls from Docker Hub when you meant your own registry, or runs a different image on Thursday than on Tuesday.
The devops registry lesson makes the case for digests in deployments. This lesson is about reading names precisely.
The grammar
The distribution/reference package that Docker, containerd and most registries use defines it:
reference := name [ ":" tag ] [ "@" digest ]
name := [domain "/"] path-component ["/" path-component]*
tag := [\w][\w.-]{0,127}
digest := algorithm ":" hex (sha256:… is 64 hex characters)
Path components are lowercase letters and digits with ., _, __ or - between them, which is why MyApp is never a valid repository. A tag is at most 128 characters of letters, digits, _, . and -, and can’t start with . or -.
How Docker fills in the gaps
The rules live in splitDockerDomain in that package’s normalize.go. I ported the function to Python and fed it some names:
nginx -> docker.io/library/nginx:latest
nginx:1.31 -> docker.io/library/nginx:1.31
bitnami/redis -> docker.io/bitnami/redis:latest
ghcr.io/acme/api:2.4.1 -> ghcr.io/acme/api:2.4.1
localhost:5000/api -> localhost:5000/api:latest
registry:5000/api -> registry:5000/api:latest
myregistry/api -> docker.io/myregistry/api:latest
index.docker.io/library/nginx -> docker.io/library/nginx:latest
alpine@sha256:f59abe65… -> docker.io/library/alpine@sha256:f59abe65…
The rule for the first component: it’s a registry if it contains a . or a :, or is exactly localhost. Otherwise it’s a namespace on Docker Hub. So myregistry/api goes to Docker Hub, which is a confusing failure and, if someone registers that Docker Hub name, a supply-chain risk. Always write internal registries with a dot or a port. A bare name gets library/, Docker Hub’s namespace for official images. No tag and no digest means :latest.
Other tools don’t all do this. Podman, for example, resolves short names through an alias list or asks, as the alternatives lesson showed. Fully qualified names behave the same everywhere.
Tags: labels that move
A tag is a pointer stored in the registry. Pushing the same tag again moves it, without warning. Image maintainers use that on purpose. I asked Docker Hub for six alpine tags with HEAD requests, which return the digest without downloading anything:
latest sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf
3 sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf
3.24 sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf
3.24.4 sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf
3.23 sha256:469c9ea410b9215eaee7976ba6c0639039b444be8e5d638f7abbada189971eb2
edge sha256:020dfcbaaf4cc1078bf2d9c7ba31a8466e334061dcd2f248001d68f79e52c000
Four tags, one image. When 3.24.5 ships, latest, 3 and 3.24 move and 3.24.4 should stay. “Should” because nothing technical stops a maintainer from re-pushing it, and official images do rebuild fixed version tags to pick up base-image security fixes. latest is only the default name for a tag. It means “whatever was last pushed as latest”, which on many repositories is not the newest version at all.
Digests: names that can’t move
A digest is the SHA-256 of a manifest or index. I fetched alpine:latest’s index and hashed it: shasum -a 256 gave f59abe65…, the same value the registry returned in Docker-Content-Digest. Because the name is the hash, a registry can’t serve different bytes under it, and the client checks. Pulling alpine@sha256:f59abe65… gives the same image on every machine, every time.
You can combine them. The pull reference documents that “a digest takes the place of the tag”, so in nginx:1.31@sha256:6a3d… Docker uses the digest and the tag is a label for humans and for update tools like Renovate and Dependabot, which bump both together.
docker images --digests # registry digests of local images
docker inspect -f '{{json .RepoDigests}}' alpine # same, for one image
docker buildx imagetools inspect alpine:3.24 # the digest straight from the registry
Don’t confuse these with IMAGE ID. That’s a local identifier for the image in your store, not necessarily what the registry calls it. Pin the value from RepoDigests or the registry.
A naming policy that works
- Fully qualify every name in Dockerfiles, Compose files and manifests:
docker.io/library/postgres:17.6, notpostgres. - Pin a version tag in
FROMlines and dev configs, and pin a digest (with its tag) in production deploys. - Tag your own images with the Git commit SHA plus a version, and never re-push a version tag. The tagging lesson builds this out.
- Use
latestonly for “try the newest”, never as a deploy target.
About the video
The embed is all of anthonywritescode’s “docker pull by sha256 digest (advanced) anthony explains #537”, March 2023, 9 minutes. Its chapters are an intro, a shell script, the Docker commands for pulling by digest, inspecting the manifest, and a correction he makes at the end. It’s the hands-on version of the digest section. It doesn’t cover how names are normalized or the localhost and dot rule, which the lesson adds. English was judged from the channel and its English caption track. LimeGuru’s video in deeper explains digests against hashes more slowly.
What was run: the normalization table came from a Python port of splitDockerDomain in distribution/reference, and the tag digests and the index hash from HEAD and GET requests to Docker Hub’s registry API, made by a short Python client with an anonymous token. Nothing ran in Docker. The grammar is quoted from reference.go, and the tag-plus-digest behaviour from the docker image pull reference, checked 2026-11-28.
Where this fits
A name points at a manifest, and a manifest points at layers. Next, what those layers are on disk: layers, overlayfs and copy-on-write.
Check yourself
docker pull myregistry/api fails with 'repository does not exist' even though your registry at myregistry:443 has that image. Why?
myregistry has no dot or colon and isn't localhost, so Docker treats it as a Docker Hub namespace and asks Docker Hub. Use myregistry.example.com/api or myregistry:443/api.
alpine:3.24.4, alpine:3.24, alpine:3 and alpine:latest all have the same digest today. Will they next year?
Probably not. Floating tags move as new releases ship. 3.24.4 should stay put, by convention rather than guarantee, while 3.24, 3 and latest move to newer releases.
Why might a team write nginx:1.31@sha256:6a3d… instead of just one of the two?
The digest guarantees the exact image. The tag tells a reader, and tools like Renovate, which version it is. Docker uses the digest and ignores the tag for the pull.
Is the IMAGE ID that docker images prints the same as the digest you'd pin in production?
Not necessarily. The image ID is a local identifier. The registry digest, shown in RepoDigests or with docker images --digests, is what other machines can pull.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.