Image Tags vs Digests
What you'll learn: How container images use human-friendly tags and machine-precise digests for different versioning needs.
The Two Ways to Reference Images
When you pull a container image, you can reference it in two fundamentally different ways: by tag or by digest. Each serves a distinct purpose in the container ecosystem.
Tags: Mutable and Human-Friendly
An image tag is a label like nginx:latest or myapp:v1.2.3. Tags are designed for humans—they're memorable, meaningful, and easy to type. However, tags are mutable: the same tag can point to different image content over time. If you rebuild myapp:latest tomorrow, the tag stays the same but the underlying image changes.
Analogy: Think of a tag like a bookmark labeled "Current Draft." The bookmark name doesn't change, but the document it points to might be updated daily.
Digests: Immutable and Precise
An image digest is a cryptographic hash like sha256:a1b2c3d4... that uniquely identifies exact image content. Digests are immutable—once created, they always reference the same bytes. If even one pixel in an image file changes, you get a completely different digest.
Analogy: A digest is like a document's fingerprint—unique and unchangeable for that exact version.
When to Use Each
- Use tags for development, human communication, and convenient references (
docker pull myapp:latest) - Use digests for production deployments, security audits, and guaranteed reproducibility (
docker pull myapp@sha256:a1b2c3d4...)
Many teams use tags during development but deploy with digests to ensure they run the exact tested version, preventing surprise updates.
Key Takeaway: Tags are mutable pointers for human convenience; digests are immutable identifiers guaranteeing precise versioning and reproducibility.