Image Tags in Docker: The Names, Labels and Version Marks of Container Images

Image Tags in Docker: The Names, Labels and Version Marks of Container Images

A friendly, in-depth guide to what Docker image tags are, how they really work behind the scenes, why the famous "latest" tag is misunderstood, and how to tag, pull, promote and secure images with confidence, explained from scratch.

Imagine a pantry full of glass jars. Each jar has a sticky note on the front saying things like “strawberry jam” or “strawberry jam, new batch”. Sticky notes are wonderfully handy, because you can find what you want quickly. But they have a weakness: anyone can peel a note off one jar and stick it on another. Tomorrow, “new batch” might point to a completely different jar. Now imagine that every jar also has a barcode printed on the bottom that is unique to the exact contents and can never be moved. The sticky notes are Docker image tags, and the barcode is the image digest. Understanding the difference between the two is the key to using Docker safely.

1What Is a Docker Image Tag?

Let us start with a simple, clear definition.

The plain-English definition

A Docker image is a packaged program together with everything it needs to run. An image tag is a short, human-friendly label attached to an image, most often used to mark its version. Instead of remembering a long string of random-looking characters, you can say “give me version 1.25 of this program”, and the tag tells the system which image you mean.

Tags are usually written after the image name, separated by a colon. For example, the name of an image family, then a colon, then a label such as a version number. When you ask Docker for an image without any tag, it quietly assumes a tag called latest.

Simple Analogy

Think of software releases as editions of a book. The book title is the image name, and the edition number is the tag. Asking for “the third edition” is much easier than asking for a book by its exact shelf position and page count. The tag is the edition label that makes the request friendly.

Why tags exist

Software changes constantly. A team releases a new version, fixes a bug, patches a security hole, or builds a special variant for a different operating system. Without labels, nobody could tell these versions apart. Tags give every release a readable name, let teams keep several versions available at once, and make it possible to move forward or roll back in a controlled way.

Purpose 1

Versioning

Mark which release of the software an image contains.

Purpose 2

Variants

Distinguish flavors of the same software, such as a slim or full version.

Purpose 3

Traceability

Link an image to the exact source code change or build that produced it.

Purpose 4

Promotion

Mark an image as approved for testing, staging or production.

Purpose 5

Rollback

Return to a previous known-good version quickly when something goes wrong.

!
Common Misconception

Many beginners believe a tag is a permanent, fixed identity of an image. It is not. A tag is only a label, and labels can be moved. This single fact explains most of the surprises and security problems people meet with tags.

2The Anatomy of an Image Reference

An image name has several parts, and each part answers a different question.

When you tell Docker which image to use, you write what is called an image reference. A full reference can contain up to five pieces. Most of the time you only write a few of them, and Docker fills in sensible defaults for the rest.

flowchart LR
  A["Registry host: where the image is stored"] --> B["Namespace: the owner or organization"]
  B --> C["Repository: the image family name"]
  C --> D["Tag: the human-friendly version label"]
  D --> E["Digest: the exact content fingerprint"]
        
FIG 1 — The parts of a full image reference, from location to exact fingerprint
PartQuestion it answersDefault if you leave it out
Registry hostWhich server holds the image?Docker Hub
NamespaceWho owns the image?The special library namespace for official images
RepositoryWhich image family is it?No default, you must supply it
TagWhich version or variant?latest
DigestExactly which content?None, the tag is resolved to whatever it currently points to
Simple Analogy

Think of a postal address. The country and city tell you the general location, the street name says which road, the house number says which building, and the flat number says exactly which door. Every part narrows the search. An image reference narrows from the server to the exact content in the same way.

What Docker fills in for you

If you write only a short name such as an official image, Docker assumes the default registry, Docker Hub, and the special namespace used for officially maintained images. It also assumes the tag latest. So a very short name is really shorthand for a much longer full reference. Seeing the long form once makes it easier to understand what actually gets downloaded.

i
Good to Know

When you use a private registry, such as one run by your company or your cloud provider, you must include its host name at the start of the reference. Otherwise Docker looks on the default public registry and will not find your private image.

3How Tags Work Inside: Labels That Point

The secret of tags is that they are not part of the image at all.

The image and its fingerprint

Every image has a unique fingerprint, called a digest, calculated from its content. If even one byte changes, the fingerprint changes completely. Because of this, the digest identifies exactly one image and can never point to anything else. This style of naming, where the name is derived from the content, is called content-addressable.

Tags as movable pointers

A tag is stored separately, by the registry or by your local Docker installation, as a simple note saying “this label currently points to that fingerprint”. The image itself does not contain its tags. This has several important consequences.

1

One image can have many tags

The same image may be known as a full version number, a shorter version number and a friendly alias all at once. They are just several sticky notes on one jar.

2

Adding a tag copies nothing

Giving an existing image another tag does not duplicate its data. It only adds one more pointer, so it is instant and uses almost no space.

3

A tag can be moved

Pushing a new image under an existing tag makes the tag point to the new image. The old image is still there, but it may no longer carry that label.

4

Removing a tag does not always remove the image

Deleting a label only removes that pointer. The image data is removed only when no tags and no containers refer to it any longer.

flowchart TD
  I["Image with digest sha256 abc123"]
  T1["Tag 1.4.2"] --> I
  T2["Tag 1.4"] --> I
  T3["Tag 1"] --> I
  T4["Tag stable"] --> I
  J["Older image with digest sha256 def456"]
  T5["Tag 1.4.1"] --> J
        
FIG 2 — Many tags can point to the same image, and each image keeps a unique fingerprint
Simple Analogy

In a large office, one person might be known by their full name, their nickname and their job title. All of those names point to the same person. But a job title such as “team lead” can be given to someone else next year. The tag “team lead” moved, while the person, the digest, stayed the same.

A tag moving over time

sequenceDiagram
  participant Pub as Publisher
  participant Reg as Registry
  participant You as Your machine
  Pub->>Reg: Push image A with tag 2.0
  You->>Reg: Pull tag 2.0
  Reg-->>You: Image A
  Pub->>Reg: Fix a bug, push image B with the same tag 2.0
  You->>Reg: Pull tag 2.0 again later
  Reg-->>You: Image B, a different image under the same label
        
FIG 3 — The same tag can point to different images at different times
!
Key Insight

Two machines that pulled the same tag on different days may hold different images. If you need certainty that two machines run exactly the same thing, the tag alone cannot promise it, but the digest can.

4What Happens When You Pull a Tag

A short journey from a friendly name to files on your disk.

Pulling an image feels like a single step, but Docker actually performs a small conversation with the registry. Knowing the steps explains why a tag is only a starting point, and why the digest is what really decides the content you receive.

sequenceDiagram
  participant You as You
  participant DK as Docker
  participant RG as Registry
  You->>DK: Pull name and tag
  DK->>DK: Fill in default registry and tag if missing
  DK->>RG: Ask which image this tag points to
  RG-->>DK: Manifest or index, with its digest
  DK->>DK: If it is an index, choose the image for this platform
  DK->>RG: Request only the layers not already stored locally
  RG-->>DK: Send the missing layers
  DK->>DK: Verify layers against their fingerprints
  DK->>DK: Record the tag locally, pointing to the digest
  DK-->>You: Report the digest of the pulled image
        
FIG 4 — Pulling a tag resolves it to a digest, then downloads only what is missing
1

Complete the reference

Docker adds the default registry and the default tag where you left them out, so the request is fully specified.

2

Resolve the tag

The registry answers with the image description that the tag points to at this moment, and its digest.

3

Pick the right platform

If the tag points to an index, Docker selects the entry that matches your operating system and processor type.

4

Download missing layers

Layers you already have are skipped, so pulling a slightly newer image is often very fast.

5

Verify and store

Each layer is checked against its fingerprint, and your local tag is recorded as pointing to the received image.

Simple Analogy

Ordering a book by its title is like using a tag. The bookshop looks up which edition is currently sold under that title, checks the stockroom, and sends only the pages you do not already own. The receipt lists the exact edition number, which is the digest you can quote later.

i
Useful Habit

After a pull, note the digest that Docker reports. If you ever need to be sure you are running the same image later, that digest is the reliable proof, not the tag you typed.

5The Famous “latest” Tag and Its Myths

The most used tag is also the most misunderstood.

What latest really is

The tag latest is simply a default. If you do not name a tag when you build, tag or pull an image, Docker uses latest. There is nothing magical about it. It does not mean the newest image, the most stable image, or the most recently pushed image. It means whatever the publisher decided to label as latest, and some publishers forget to update it at all.

Myth 1

“Latest always means newest”

False. It is only a label that the publisher moves when they choose. It may lag behind other tags.

Myth 2

“Latest is the safest choice”

False. It may point to a version with breaking changes, or to a release you have not tested.

Myth 3

“Latest auto-updates my container”

False. Running containers never change by themselves. A new pull is needed, and the container must be recreated to use it.

Myth 4

“Latest is a special reserved word”

False. It is an ordinary tag name that Docker chooses when you do not name one.

Simple Analogy

Ordering “the usual” at a cafe works only when the staff and you agree on what the usual is. If a new barista changes the recipe, tomorrow’s usual is a different drink. Using latest in a serious system is like relying on the usual at a cafe with a rotating staff.

Why latest causes trouble

Where latest is acceptable

  • Quick personal experiments and demonstrations
  • Throwaway learning environments
  • Trying a tool for the first time

Where latest is dangerous

  • Production deployments, where surprises cause outages
  • Shared build pipelines, where results become unrepeatable
  • Security-sensitive systems that need to know exactly what runs
  • Rollbacks, because there is no clear previous version to return to
ANTI-PATTERN-01 Avoid
Problem

Using the latest tag for base images and production deployments.

Why It’s Harmful

Builds are not repeatable. Yesterday’s successful build may fail today because latest now points to a different image, and nobody can say exactly what is running.

Correct Approach

Use explicit version tags, and for critical systems pin the exact digest. Use latest only where surprises do not matter.

6Tags versus Digests: Labels and Fingerprints

Both identify an image, but they make very different promises.

AspectTagDigest
What it isA human-friendly labelA content fingerprint calculated from the image manifest
Can it change what it points to?Yes, tags can be movedNo, it always identifies exactly one image
ReadabilityEasy to read and rememberLong and hard to read
Best forCommunicating versions, convenience, updatesReproducibility, security, exact deployments
Automatic updatesPossible when a tag movesNone, you change it deliberately
RiskSilent change of contentsMissing security patches unless you update on purpose
Simple Analogy

A person’s nickname is easy and friendly, but two people in different towns can share it, and it can be given to someone new. A passport number is ugly and long, but it identifies exactly one person forever. Use nicknames for talking, and passport numbers for anything that must be exact.

Combining both

You can write both a tag and a digest in the same reference. When you do, Docker uses the digest to select the image, and the tag serves as a human-readable hint for whoever reads the configuration later. Many teams follow the pattern of writing a readable version tag for people, together with the digest for machines. Tools that automatically propose updates can then read the tag and refresh the digest when a new version appears.

1

Choose a readable version tag

Pick a specific version rather than latest, so humans can understand the intent.

2

Resolve it to a digest

Look up which digest that tag points to right now, after testing that image.

3

Record both in your configuration

Store the tag for readability and the digest for exactness.

4

Update on purpose

When a patched version is released, test it and replace the tag and digest together, ideally through an automated review process.

i
Balance Tip

Pinning by digest gives certainty but freezes you in time. Without a process to refresh pinned digests regularly, you may keep running an image that has known security problems. Certainty and freshness need a routine that connects them.

7Tag Naming Rules and Limits

Tags are flexible, but they are not free-form text.

Rule

Allowed characters

Letters, digits, underscores, periods and hyphens.

Rule

Length limit

A tag may be at most one hundred twenty-eight characters long.

Rule

Starting character

A tag cannot begin with a period or a hyphen.

Rule

No spaces or slashes

Spaces, slashes and colons are not allowed inside a tag, because they have special meaning in the full reference.

Rule

Repository names

The image name part must be lowercase, with parts separated by slashes, and may use a limited set of separators.

Simple Analogy

These rules are like the rules for a web address or a file name. Systems need names that are simple and unambiguous, so that programs can split them into parts reliably without guessing.

Practical naming advice

Be consistent

Agree on one naming convention for the whole team, and document it. Mixed styles make images hard to search and automate.

Be meaningful

A tag should tell a stranger something useful, such as the version, the source revision or the variant. Names like “test2” or “final-final” tell nobody anything.

Avoid clever characters

Branch names often contain slashes, which are not allowed in tags. Replace them with hyphens when you turn a branch name into a tag.

Keep them short enough to read

Very long tags are allowed but awkward. Put detailed information in labels and metadata inside the image instead.

!
Common Mistake

Putting uppercase letters in the repository name, or adding a slash to a tag. Docker will reject these, and the error message may look confusing until you remember the naming rules.

8Common Tagging Strategies

There is no single correct way to tag. Here are the popular patterns and when each shines.

StrategyExample ideaStrengthWeakness
Semantic versionMajor, minor and patch numbers such as 2.4.1Clear meaning for users and upgradesNeeds discipline to keep numbers honest
Floating version tagsShorter forms such as 2.4 or 2 that move to the newest matching releaseAutomatic patch updates within a rangeContents change silently
Source revision tagShort code of the commit that produced the imageExact traceability to source codeNot human-friendly for versions
Build numberSequential number from the build systemSimple orderingMeaningless outside that system
Date or timestampYear, month and day of the buildEasy to see ageDoes not tell what changed
Branch tagName of the source branch, cleaned of slashesHandy for testing feature workMoves constantly, so unreliable
Environment tagNames such as staging or productionEasy to rememberMutable labels that hide which version is where

The layered tagging pattern

Many well-run projects apply several tags to the same image at release time. This lets different users choose different levels of stability. The exact, immutable-in-practice tags are for careful users, and the floating tags are for people who want easy updates.

1

Full version tag

Names the exact release, such as major, minor and patch together. It should never be reused for a different image.

2

Minor version tag

Moves forward with each patch release in the same minor line, so users receive bug fixes automatically.

3

Major version tag

Moves forward with each minor and patch release in the same major line, for users who accept new features but not breaking changes.

4

Revision tag

Records the source commit, giving a precise link back to the code.

Simple Analogy

A newspaper is available by exact date, by month and by year. If you need to cite exactly one issue, you use the date. If you want to browse everything from a month, you use the month. Layered tags give the same range of precision.

i
Design Tip

For your own applications, always keep one tag that is unique to each build, such as the source revision, and never reuse it. That unique tag is your reliable handle for rollbacks, audits and investigations.

9Variant Tags: Flavors of the Same Software

The same program may be offered in several builds, and tags tell them apart.

Publishers of popular images often provide several flavors, and they use suffixes on the tag to distinguish them. Learning to read these suffixes helps you pick the right image the first time.

Variant

Slim

A reduced image with fewer extra packages, smaller to download and with less to attack, but possibly missing tools you expect.

Variant

Alpine

Built on a very small Linux distribution. Tiny, but it uses different system libraries, which occasionally causes compatibility surprises.

Variant

Operating system release name

Names of Linux releases in the tag show which distribution version the image is built on.

Variant

Language runtime version

For images of programming languages, the tag shows which language version is included.

Variant

Build tools included

Some variants include compilers and development tools for building, while others carry only what is needed to run.

Variant

Windows variants

Images for native Windows containers use tags naming the Windows edition and version.

flowchart TD
  S["Need an image for my language runtime"] --> Q1{"Is the smallest possible size critical?"}
  Q1 -->|"Yes"| A["Try slim or alpine variants and test carefully"]
  Q1 -->|"No"| Q2{"Do I need build tools and full compatibility?"}
  Q2 -->|"Yes"| B["Use the full variant on a named OS release"]
  Q2 -->|"No"| C["Use the slim variant on a named OS release"]
        
FIG 5 — A simple way to think about choosing between image variants
Simple Analogy

A phone model may come in a standard, a compact and a large edition. The name of the phone is the repository, and the edition is the variant tag. Same brand, same core features, but different size and trade-offs.

!
Read the Documentation

Suffix meanings are conventions published on each image’s page, not universal rules. Always read the description of the specific image to see exactly what its variants contain and which are maintained.

10Multi-Architecture Images and Tags

One tag can quietly serve different kinds of computers.

The problem

Computers use different processor designs, called architectures. Common ones are the traditional Intel and AMD design and the ARM design found in many phones, laptops and cloud servers. A program built for one design usually cannot run natively on the other. A container image therefore has to be built separately for each architecture.

The solution: one tag, several images

A single tag can point to a special index that lists several images, one for each architecture and operating system. When you pull the tag, Docker looks at the index, sees which platform your machine uses, and downloads the matching image automatically. This is why the same short image name works on your laptop and on a server, even when they have different processors.

flowchart TD
  T["Tag 2.0"] --> IX["Index listing platform images"]
  IX --> A1["Image for Intel and AMD Linux"]
  IX --> A2["Image for ARM Linux"]
  IX --> A3["Image for Windows"]
  M1["Your Intel laptop pulls tag 2.0"] --> A1
  M2["Your ARM server pulls tag 2.0"] --> A2
        
FIG 6 — A multi-platform tag points to an index that lists one image per platform
Simple Analogy

A phone charger sold as one product may include several plug adapters in the box. The product name is the tag, and the plug for your country is chosen for you when you use it. You buy one item, and it fits wherever you go.

Practical points

1

Build for every platform you deploy to

Modern build tools can produce a multi-platform image in one step and publish it under a single tag.

2

Digests exist at two levels

The index has its own digest, and each platform image has its own digest. Pinning the index digest keeps the multi-platform behavior, while pinning a platform digest fixes one specific image.

3

Beware of accidental emulation

On a machine with a different processor, Docker may run an image built for another architecture through emulation, which works but is slower. If performance is poor, check which platform was pulled.

4

Avoid per-architecture tags when you can

Older setups used separate tags such as one suffix per processor type. A single multi-platform tag is simpler for users, though separate tags can still be handy for debugging.

i
Modern Reality

With many developers on ARM laptops and many servers on Intel or AMD, and increasingly ARM servers too, multi-platform tags have moved from a nice extra to an everyday necessity.

11Working with Tags: Create, Retag, Push, Pull and Remove

The everyday actions, explained in plain words.

Action

Tag at build time

When you build an image, you can give it a name and a tag right away. If you leave the tag out, it becomes latest.

Action

Retag an existing image

Add another name and tag to an image you already have. This copies no data. It adds one more label, and it is how you prepare an image for a different registry.

Action

Push

Upload an image under a given name and tag to a registry. If the tag already exists there, it now points to your image.

Action

Pull

Download the image that a tag currently points to. Without a tag, latest is assumed.

Action

List

See the images on your machine with their names, tags and sizes. Images without a tag appear with a placeholder.

Action

Remove a tag or an image

Removing by tag deletes just that label. The image data goes away only when its last label is removed and no container uses it.

What are “none” images?

When you rebuild an image under the same tag, the tag moves to the new image, and the old one loses its label. It still exists on your disk, but with no tag, so it appears in lists with a placeholder instead of a name. These are often called dangling images. They are harmless leftovers, but they consume disk space until you clean them up.

Simple Analogy

Peeling a sticky note from an old jar and putting it on a new jar leaves the old jar unlabeled on the shelf. It is still full of jam, but nobody can find it by name. Housekeeping means checking those unlabeled jars from time to time and throwing away the ones you do not need.

!
Common Mistake

Assuming that pushing a tag creates a new, separate image. If the tag already exists in the registry, your push silently replaces what it points to, and everybody who pulls it afterwards gets your version.

12Tags and Layers: Why Different Tags Share Data

Tags are cheap because the heavy parts of images are shared.

An image is a stack of read-only layers. Two different tags, such as two neighboring versions of a program, often share most of their layers, because most of the software inside did not change. When you pull the second version, Docker downloads only the layers you do not already have. The same sharing happens in the registry, which stores each layer once and lets many images point to it.

flowchart TD
  L1["Shared base layers"]
  L2["Shared runtime layers"]
  A["Tag 1.0: application layer for version 1.0"]
  B["Tag 1.1: application layer for version 1.1"]
  A --> L2
  B --> L2
  L2 --> L1
        
FIG 7 — Two tags can share almost all of their layers and differ only in the top one
Simple Analogy

Two editions of a cookbook may share most of their pages, with only a few new recipes added. If you already own the first edition, you only need the changed pages to complete the second. Layers work the same way, which is why new tags rarely mean a full download.

Effect

Small downloads

Only changed layers travel over the network when you move between versions.

Effect

Small storage

Ten tags of the same application rarely take ten times the disk space.

Effect

Fast tagging

Adding a tag touches no layer data at all.

Effect

Careful deletion

A layer is removed only when no remaining image needs it, so deleting one tag rarely frees as much space as you expect.

!
Common Surprise

Removing an old tag may free very little disk space if newer tags share its layers. Space is reclaimed only for layers that nothing else uses, so judge cleanup by unused layers, not by the number of tags removed.

13Tags in the Registry: Mutability, Immutability and Cleanup

What the registry does with your tags decides how trustworthy they are.

Mutable tags by default

By default, most registries let anyone with permission push to an existing tag and change what it points to. This is convenient, because floating tags such as a major version tag depend on it. But it also means that any tag can change under your feet, including by accident, for example when two pipelines push to the same tag at nearly the same time.

Immutable tags

Some registries offer a setting that makes tags immutable, so once a tag has been pushed it cannot be pointed at a different image. Attempts to overwrite it are refused. This protects the exact version tags you rely on for audits and rollbacks. Support and details differ between registries, so check what yours offers. Many teams combine both styles: immutable tags for exact versions and a small set of intentionally movable tags for convenience.

Tag kindBehaviorGood use
Immutable exact tagNever changes once pushedReleases, audits, rollbacks
Floating tagDeliberately moves to newer imagesConvenience for users who accept updates
Accidentally mutable tagOverwritten without anyone planning itNothing, this is the source of many problems
Simple Analogy

A museum has permanent labels carved into stone next to exhibits, and temporary paper signs for special events. Permanent labels record history and cannot be swapped. Paper signs change often. Registries let you choose which of your tags are carved in stone.

Untagged images and cleanup

When a tag moves, the previous image may be left with no tags. Registries keep such images until they are cleaned up. Over time, storage grows, so most registries offer retention policies: rules such as keeping only the most recent set of images, or removing untagged images after a number of days. Cleanup is valuable, but it must be designed carefully, because deleting an image that a running system still needs, especially one referenced only by digest, causes failures.

1

Decide what must be kept

Release images and anything currently deployed anywhere should be protected from deletion.

2

Define retention rules

Keep a number of recent builds per branch, and expire short-lived test images quickly.

3

Remove untagged leftovers

Untagged images that nothing references can be deleted after a safe waiting period.

4

Reclaim the space

Many registries need a garbage collection step to physically free the storage of deleted images and unused layers.

i
Tip

Test cleanup rules in a reporting or dry-run mode first, and make sure they cannot delete anything your production systems still pull.

14Tags in CI/CD: Build Once, Promote by Tagging

Tags shine in delivery pipelines, when used with discipline.

The core idea: promote the same image

A healthy pipeline builds an image once, gives it a unique tag such as the source revision, and then moves that exact image through testing and release. When the image is approved for the next stage, the pipeline does not rebuild it. It simply adds a new tag, such as a release version, to the same image. This guarantees that what was tested is exactly what gets deployed.

sequenceDiagram
  participant Dev as Developer
  participant CI as Build pipeline
  participant Reg as Registry
  participant Test as Test environment
  participant Prod as Production
  Dev->>CI: Push source change
  CI->>CI: Build image once
  CI->>Reg: Push image tagged with source revision
  Test->>Reg: Pull by revision tag
  Test->>Test: Run automated tests
  CI->>Reg: Add release version tag to the same image
  Prod->>Reg: Pull by release tag or digest
  Prod->>Prod: Deploy and record the digest
        
FIG 8 — Build once, then promote the same image by adding tags, never by rebuilding
Simple Analogy

A factory inspects a product, then attaches an “approved” sticker to that same product before shipping it. It does not build a second, slightly different product and ship that one. Adding a tag is attaching the sticker, and rebuilding would be shipping an untested lookalike.

Pipeline tag

Source revision

Unique per build. The reliable handle for tracing and rollback.

Pipeline tag

Release version

Added when the image is approved for release, following your version numbering.

Pipeline tag

Branch or pull request tag

Short-lived tags for testing feature work, cleaned up automatically.

Pipeline tag

Floating convenience tags

Moved on release for users who follow a version line.

ANTI-PATTERN-02 Avoid
Problem

Rebuilding the image separately for each environment, using tags like staging and production that are moved around.

Why It’s Harmful

Each rebuild can produce a slightly different image because of changed dependencies or base images. What passed testing is not what reaches production, and nobody knows which version is where.

Correct Approach

Build once with a unique tag, promote by adding release tags to the same image, and record the digest that was deployed.

15Tags in Compose and Kubernetes

Configuration files carry image references, so tag choices live there too.

In Docker Compose

A Compose file lists each service and the image it uses, including the tag. If the tag is a floating one, then a new pull may bring a different image, and your local environment can change without any edit to the file. Pinning versions in Compose files keeps every team member’s environment the same and makes problems reproducible.

In Kubernetes

In Kubernetes, each workload definition names its container images with tags or digests. There is an important default behavior to remember: when an image reference uses the latest tag, or no tag at all, Kubernetes by default tries to pull the image every time a container starts. With a specific tag, it reuses an image already stored on the node. This means mutable tags can produce different images on different nodes, depending on when each node last pulled.

Reference styleDefault pull behaviorRisk
No tag or latestPulls each time a container startsDifferent nodes may run different images over time
Specific version tag that never movesUses a local copy if presentLow, if the tag is truly immutable
Specific tag that gets overwrittenNodes with a cached copy keep the old oneMixed versions across nodes
DigestExact image every timeLowest, but needs an update routine
Simple Analogy

Imagine several restaurants in a chain receiving the same recipe card. If the card says “use today’s special sauce”, each branch might use a different sauce depending on when they last checked. If it says “use sauce batch number 4471”, every branch uses exactly the same one.

Rollouts and rollbacks

Updating a deployment usually means changing the image tag in its definition. The platform then replaces containers gradually. To roll back, you return to the previous tag or digest. This works smoothly only if the previous tag still points to the same image it did before, which again argues for unique, immutable tags for every build.

i
Good Practice

Keep the image reference in your configuration files in version control. Every deployment change then becomes a reviewed, recorded edit, and the history tells you exactly which image ran when.

16Security and Supply-Chain Considerations

A movable label is also a movable trust decision.

Why tags matter for security

When you reference an image by tag, you are trusting whoever controls that tag to keep pointing it at something safe. If the publisher’s account is compromised, or if a careless or malicious change is pushed to a popular tag, every system that pulls it afterwards receives the altered image. Nothing in your configuration changed, yet what you run did. This is why security guidance so often says to pin by digest.

flowchart LR
  P["Trusted image under tag 3.1"] --> R["Registry"]
  X["Attacker or mistake pushes a different image under tag 3.1"] --> R
  R --> S["Your servers pull tag 3.1 again"]
  S --> B["Unexpected code now runs"]
  D["Pinned digest"] -. "Not affected, points to the original content" .-> P
        
FIG 9 — A moved tag can change what runs without any change to your configuration, while a pinned digest cannot
Simple Analogy

Trusting a tag is like trusting a street sign. If someone rotates the sign, drivers end up in the wrong place without knowing. A GPS coordinate, the digest, does not rotate, so it always leads to the same spot.

Defense

Pin by digest

For critical images, use the digest so that content cannot silently change.

Defense

Use trusted publishers

Prefer official and verified images, and beware of look-alike names that imitate popular ones.

Defense

Sign and verify images

Signatures prove an image came from your pipeline. Deployment systems can refuse unsigned images.

Defense

Scan regularly

Vulnerability scanners check what is inside an image, and should run again on a schedule, since new flaws are discovered constantly.

Defense

Restrict who can push

Limit write access to release tags, so only your pipeline can create or change them.

Defense

Mirror important base images

Keep trusted copies in your own registry so that outside changes or outages cannot affect your builds.

ANTI-PATTERN-03 Avoid
Problem

Pulling images from unknown publishers by a popular-looking name and a floating tag, and running them with broad permissions.

Why It’s Harmful

Look-alike names and moved tags are common ways to slip harmful code into systems.

Correct Approach

Verify the publisher, prefer official or verified sources, pin digests, scan, and run with the least privilege possible.

!
The Freshness Trade-off

Pinning by digest protects you from silent changes but also from silent security fixes. Set up an automatic process, such as a scheduled job or a dependency update tool, that proposes new digests for review so that you stay both safe and current.

17Traceability, Labels and Governance

A tag says little by itself. Good teams attach more information and keep records.

Metadata inside the image

Images can carry labels, which are small key and value pairs stored in the image’s metadata. Standards exist for recording useful facts such as the source repository, the source revision, the build date, the author and the license. Together with the tag, these let anyone who inspects an image work out where it came from and how it was made.

Question you may faceWhere the answer should live
Which version is this?Version tag and a version label
Which source code built it?Revision tag and a source revision label
When was it built?Creation date in the image metadata
What software is inside?A software bill of materials attached to the image
Who approved it for production?Pipeline records and signatures
Which digest is running now?Deployment records and cluster inspection
Simple Analogy

A food package has a name on the front, but the back carries the ingredients, the batch number and the expiry date. The tag is the name on the front. Labels and records are the details on the back that matter when something goes wrong.

Governance habits

1

Write down the tagging policy

Document which tags exist, which are immutable, which move, and who may change them.

2

Enforce it automatically

Use registry settings and pipeline checks to prevent overwriting release tags and to reject unapproved names.

3

Record what is deployed

Store the digest of every deployed image, so an investigation never depends on which tag pointed where at the time.

4

Audit and review

Periodically review which images are in use, which are outdated and which base images need refreshing.

i
Monitoring Tip

Track how many running containers use each image and how old those images are. A dashboard showing images that are many months old is an early warning that patching has fallen behind.

18Design Patterns, Anti-Patterns and Best Practices

A short catalogue of what works and what quietly hurts.

Patterns worth adopting

Unique tag per build

Give every build a tag that is never reused, such as the source revision, and treat it as the permanent handle for that image.

Immutable release tags, intentional floating tags

Make exact version tags immutable, and keep a small, documented set of floating tags for convenience.

Pin critical base images by digest

Combine a readable version tag with a digest, and refresh both through a reviewed, automated process.

Build once, promote by retagging

Never rebuild for each environment. Add tags to the tested image as it moves forward.

Record the deployed digest

Keep a record of which digest ran where and when, so investigations and rollbacks are precise.

More anti-patterns to avoid

ANTI-PATTERN-04 Avoid
Problem

Using environment names such as production or staging as image tags that get moved with each deployment.

Why It’s Harmful

They hide which version is actually running, break rollbacks and make audits nearly impossible.

Correct Approach

Tag images by version or revision, and express which environment runs which image in the deployment configuration.

ANTI-PATTERN-05 Avoid
Problem

Reusing an exact version tag to publish a small fix.

Why It’s Harmful

Users who trust that version number receive different contents, and caches across machines hold a mixture of old and new images.

Correct Approach

Publish a new patch version tag for every change, however small.

ANTI-PATTERN-06 Avoid
Problem

Never cleaning old images or tags, or cleaning them without checking what is still in use.

Why It’s Harmful

Storage grows without limit in the first case, and deployments break with missing images in the second.

Correct Approach

Use retention policies that protect released and deployed images and remove short-lived ones.

Do

  • Use explicit version tags in every configuration
  • Keep at least one unique tag per build
  • Pin digests for critical systems and refresh them regularly
  • Build multi-platform images when you deploy to varied hardware
  • Document and enforce your tagging policy

Do Not

  • Rely on latest in production
  • Overwrite released version tags
  • Use environment names as version tags
  • Rebuild images for each environment
  • Trust unknown publishers or look-alike names

19A Simple Team Tagging Convention You Can Adopt

A clear policy prevents most tag problems before they start.

Below is an example convention that many teams find workable. It is a starting point, not a rule. Adapt it to your tools, and write the final version down where everyone can find it.

Tag styleMeaningMutable?Who may create or move it
Source revisionUnique build, tied to a specific commitNoThe build pipeline
Full release versionAn approved release, with major, minor and patch numbersNoThe release pipeline
Minor and major versionNewest release within that lineYes, on purposeThe release pipeline
Pull request or branchTemporary image for testing a changeYesThe build pipeline, cleaned up automatically
Nightly or dateScheduled build for early feedbackNo, one per dateThe scheduled pipeline
latestMost recent release, for casual use onlyYesThe release pipeline
1

Agree the naming shape

Decide how versions, revisions and dates are written, so every tag looks familiar.

2

Decide which tags are frozen

List the tag styles that must never move, and turn on immutability in the registry for them where it is available.

3

Give the pipeline sole authority

Restrict pushing of release tags to automated jobs, so people cannot change them by accident.

4

Set retention for temporary tags

Branch and pull request images expire after a short time, while release images are kept.

5

Review the policy regularly

Revisit the convention when tools or team size change, and update the document.

Simple Analogy

A tagging convention is like the rules of a shared filing room. Everyone knows which drawer holds permanent records, which holds drafts, and who has the key to each. Without those rules, the room quickly fills with unlabeled folders and arguments.

i
Keep It Simple

Fewer tag styles are easier to enforce. Start with the source revision and the full release version, and add floating tags only when users actually ask for them.

20Troubleshooting Common Tag Problems

Most tag problems come from a handful of causes. Here is how to recognize them.

SymptomLikely causeWhat to check
Message saying the manifest or tag was not foundMisspelled name or tag, tag never pushed, or missing access to a private repositorySpelling, the registry’s list of tags, and your login
Pulled image behaves differently from yesterdayThe tag moved to a new imageCompare digests before and after, and stop relying on floating tags
Image will not start, with an architecture or format errorImage built for a different processor typeWhich platform was pulled and whether a multi-platform tag exists
Two servers run different versions of the same tagNodes pulled at different times and kept cached copiesDigests running on each server, and pull policy
Images with no name in the listTags moved to newer builds, leaving untagged leftoversClean up unused images after confirming they are not needed
Push refusedImmutable tag already exists, or no permissionRegistry tag settings and access rights
Pull from the wrong registryRegistry host missing from the referenceThe full reference, including the host name
Rollback did not restore the old behaviorThe previous tag had been overwrittenUse digests or unique per-build tags for rollbacks
1

Write down the exact reference

Copy the full image reference from the configuration, including registry host, tag and digest if present.

2

Find the digest actually running

Inspect the running container or image to learn its real fingerprint, rather than trusting the tag.

3

Compare with the registry

Look up what the tag points to in the registry now, and see whether it matches.

4

Check the platform

Confirm the image’s architecture and operating system match the machine.

5

Fix the root cause in your process

Move to unique tags, immutability or digest pinning so the same surprise cannot return.

Simple Analogy

When a parcel arrives with the wrong contents, a good investigator does not argue about the name on the box. They check the tracking number, which is the digest, and follow it to see what really happened along the way.

21Real-World Scenarios

Five common situations, and how good tagging solves them.

The build that suddenly broke

A team’s pipeline starts failing overnight, though nobody changed the code. The cause is a base image referenced by a floating tag, which moved to a release with a breaking change. After pinning the base image to a specific version and digest, builds are repeatable again.

The urgent rollback

A new release causes errors in production. Because every build carries a unique revision tag and the previous release’s tag was never overwritten, the team redeploys the earlier image within minutes, with confidence that it is exactly the one that ran before.

Mixed versions across a cluster

Some servers show old behavior and others show new, though all use the same tag. The tag had been overwritten, and servers kept cached copies from different times. Switching to immutable version tags ends the confusion.

The ARM laptop and the Intel server

A developer on an ARM laptop pushes an image that will not start on an Intel server. The fix is to publish a multi-platform image under a single tag, so each machine receives the right build automatically.

The security audit

An auditor asks exactly which image ran in production on a certain date. The team answers precisely because deployment records store digests, and images carry labels linking them to source revisions and build records.

Tag
Readable, friendly, movable
Digest
Exact, permanent, machine-friendly
Both
Human meaning with machine certainty
“A tag is a promise made by a person. A digest is a fact recorded by a machine.”

22Reading Real Tag Names: Worked Examples

Practice makes tags easy to read at a glance.

Once you know the common conventions, you can decode most tags on sight. The examples below are illustrative patterns, not a list of real images. Always confirm the meaning on the publisher’s own page.

Example tag patternHow to read itStability
Major, minor and patch numbers togetherOne exact release of the softwareVery stable, should never move
Major and minor numbers onlyThe newest patch of that minor lineMoves with each patch release
Major number onlyThe newest release of that major lineMoves often, but stays compatible in principle
Version followed by slimThat version in a reduced-size buildFollows the same stability as its version part
Version followed by an alpine markerThat version on a very small Linux baseSame, but check library compatibility
Version followed by an operating system release nameThat version built on a specific Linux releaseTied to that release’s lifetime
Short string of letters and digitsProbably a source revision from a build systemUnique per build
Word such as stable or edgeA maintainer-chosen channelMoves whenever the maintainer decides
latestWhatever the publisher last labeled soUnpredictable
1

Look for a version number

The more parts the version has, the more exact and stable the tag usually is.

2

Look for a suffix

Suffixes reveal the flavor: reduced size, tiny base, or a named operating system release.

3

Ask whether the tag moves

Shorter and vaguer tags usually move more often. Decide whether you can accept that.

4

Confirm on the publisher’s page

The description lists the supported tags, what each variant contains and how long each is maintained.

Simple Analogy

Reading tags is like reading clothing labels. A size, a fabric and a wash instruction each tell you something different, and once you have learned the symbols, a glance at the label tells you whether the garment suits you before you even try it on.

i
Rule of Thumb

For anything important, choose the most specific tag that still meets your needs, then pin its digest. The less a tag can move, the less it can surprise you.

23A Quick Glossary of Tag-Related Words

Keep this list nearby. Each word ties back to an idea from this guide.

Word

Repository

A collection of related images and their tags under one name in a registry.

Word

Registry

A server that stores and delivers images.

Word

Manifest

A small description of an image that lists its layers and settings. Its fingerprint is the image digest.

Word

Digest

A permanent content fingerprint that identifies exactly one image.

Word

Floating tag

A tag that is deliberately moved to newer images over time.

Word

Immutable tag

A tag that the registry refuses to move once it has been pushed.

Word

Dangling image

An image with no tag pointing to it, often left behind when a tag moves.

Word

Image index

A list that maps one tag to several platform-specific images, enabling multi-platform tags.

Word

Semantic version

A numbering style with major, minor and patch parts that signals the size of a change.

Word

Promotion

Marking a tested image as approved for the next stage, usually by adding a tag.

Word

Pinning

Fixing a reference to an exact tag or digest so it cannot change unexpectedly.

Word

Garbage collection

The registry process that frees storage used by deleted images and unused layers.

24Frequently Asked Questions

Q1What is a Docker image tag in one sentence?

It is a human-friendly label, usually a version, attached to an image so that you can refer to it by a readable name instead of a long fingerprint.

Q2What happens if I do not specify a tag?

Docker assumes the tag latest, whether you are building, tagging or pulling.

Q3Does latest mean the newest version?

No. It is only a default label that the publisher may or may not keep updated. Never assume it is the newest or the safest.

Q4Can an image have more than one tag?

Yes. Any number of tags can point to the same image, and adding one copies no data.

Q5Can a tag point to a different image later?

Yes, unless the registry enforces immutability. Pushing a new image under an existing tag moves it.

Q6What is the difference between a tag and a digest?

A tag is a movable, readable label. A digest is a fingerprint of the exact content and cannot point to anything else.

Q7Should I pin images by digest?

For critical systems, yes, because it guarantees exact content. Combine it with a routine that refreshes digests so you still receive security updates.

Q8Does deleting a tag delete the image?

Not necessarily. Removing a tag removes only that label. The image data is removed when no tags and no containers refer to it.

Q9What are the rules for tag names?

Letters, digits, underscores, periods and hyphens, up to one hundred twenty-eight characters, and the tag cannot start with a period or a hyphen.

Q10How does one tag work on different processor types?

The tag can point to an index listing several platform-specific images. Docker chooses the one matching your machine automatically.

Q11What tags should I use for my own application?

A unique tag per build, such as the source revision, plus release version tags added when an image is approved. Add floating convenience tags only if users need them.

Q12Why did my old images lose their names?

When you rebuild under the same tag, the tag moves to the new image and the old one becomes untagged. These leftover images can be cleaned up once you confirm they are not needed.

25Summary and Key Takeaways

A Docker image tag is a human-friendly label attached to an image, most often used to mark its version. It is stored separately from the image, so one image can carry many tags, adding a tag copies nothing, and a tag can be moved to point at a different image. The default tag latest is only a convention and does not mean newest or safest. For certainty, every image also has a digest, a permanent fingerprint of its content. Good teams give every build a unique tag, keep exact version tags immutable, build once and promote by adding tags, publish multi-platform images under a single tag, and pin critical images by digest while refreshing them through a reviewed process. With clear naming, recorded deployments and careful cleanup, tags become a reliable language for shipping software instead of a source of surprises.

Key Takeaways

  • A tag is a movable label — it points to an image, is not part of the image, and can be reassigned to a different one.
  • The latest tag is only a default — it does not mean newest or safest, so avoid it in production and repeatable builds.
  • Digests give certainty — a digest identifies exactly one image, so pin by digest for critical systems and refresh it through a routine.
  • Tag every build uniquely — a source revision tag gives you a permanent handle for tracing, audits and rollbacks.
  • Build once, promote by retagging — add tags to the tested image instead of rebuilding for each environment.
  • Protect your tags — make exact version tags immutable, restrict who can push, sign and scan images, and trust only reliable publishers.
  • Plan for platforms and cleanup — use multi-platform tags for varied hardware, and use retention rules that protect what is deployed.