Learning objectives
By the end of this module, you should be able to:
- Read image references such as repository:tag and registry/repository:tag.
- Explain the difference between a mutable tag and an immutable content digest.
- Inspect image metadata and layer history.
Image references identify artifacts
A familiar reference such as nginx:alpine combines a repository name with a tag. When a registry hostname is omitted, Docker uses its configured/default registry conventions. Tags are human-friendly labels and can be moved to point at a different image over time.
A digest identifies image content by cryptographic hash and is therefore useful when you need an immutable reference.
Images are layered
Docker images are assembled from filesystem layers plus configuration metadata. Layers can be shared between images, reducing duplicate transfer and storage when content is identical. Image history helps explain how a Dockerfile produced the artifact, although it is not a complete security record.
Registries distribute images
docker pull retrieves an image, docker push uploads a tagged image when you are authenticated and authorized, and docker image tag creates another local reference to the same image content. Production pipelines commonly push versioned images to an organizational registry instead of building directly on production hosts.
Worked examples
See the idea in practice.
Inspect a pulled image
docker pull nginx:alpine
docker image inspect nginx:alpine --format '{{.Id}} {{json .RepoDigests}}'
docker history nginx:alpine
- The image ID identifies local image content/configuration.
- RepoDigests show content-addressed registry references after pull.
- history shows the build-layer history presented by the image.
Create another tag
docker image tag nginx:alpine local/nginx-training:1.0
docker image ls local/nginx-training:1.0
- Tagging does not duplicate all layers.
- Both references can point at the same underlying image ID.
Hands-on lab
Lab — Compare tags and image identity
Goal: Create multiple references and prove that a tag is a label rather than a copy of the filesystem.
STEP 1Pull BusyBox
docker pull busybox:1.36
STEP 2Add two local tags
docker tag busybox:1.36 gnu-lab/busybox:stable
docker tag busybox:1.36 gnu-lab/busybox:demo
STEP 3Compare image IDs
for ref in busybox:1.36 gnu-lab/busybox:stable gnu-lab/busybox:demo; do id=$(docker image inspect "$ref" --format '{{.Id}}'); echo "$ref -> $id"; done
STEP 4Remove only the extra references
docker rmi gnu-lab/busybox:stable gnu-lab/busybox:demo
Verify
- All three references initially point to the same image ID.
- Removing an extra tag does not necessarily delete shared image data while other references remain.
Expected outcome
- busybox:1.36 remains available after the two local tags are removed.
If it fails
- If a pull is rate-limited, authenticate to your registry or retry according to its policy.
- If a push is denied, verify repository name, login and registry permissions.
Real-world connectionRelease pipelines commonly publish immutable version tags and record digests so deployment systems can prove exactly which artifact was released.
Avoid these traps
Common mistakes
- Assuming latest means newest or safe.
- Using only mutable tags when reproducible deployment requires an immutable artifact.
- Embedding registry credentials into a Dockerfile.
Knowledge check
Can you explain it without looking back?
Open each answer only after you have tried to answer the question yourself.
1Why is a digest stronger than a mutable tag for reproducibility?
A digest is content-addressed and changes when the image content changes; a tag can be reassigned.
2What does docker image tag do?
It creates another local image reference; it does not rebuild the image.
3Why can multiple images share storage?
Identical image layers can be reused rather than duplicated.