الانتقال إلى المحتوى
DevOps والـ CloudDocker· 6 دقائق للقراءة

The latest Tag Is Just a Name: Mutable Tags, Digests and Reproducible Deploys

latest is the default tag, not a version. It points wherever the last push left it; a digest always means the same image.

ReadIn

مقال كل يوم يفرق معاك

22 نوفمبر 2026
  • كاتب موثّق
محتويات المقال

Version 1.4.0 ships on Monday. On Wednesday, a hotfix for a customer still on 1.3 goes out from the maintenance branch, and that pipeline, like every pipeline in the company, also pushes latest. On Thursday, the autoscaler adds two servers. They start 1.3.1, while the older servers keep running 1.4.0. Nobody deployed anything, and the dashboards show the same image name everywhere.

The common misconception

The belief: latest always points to the newest version of an image, so deploying shop-api:latest means deploying the current release, and it's safe.

It's a natural reading. The name promises it. Docker applies it for you: the docker image tag reference says "If no tag is provided, Docker defaults to latest." And in a team where one pipeline builds one branch, the last image pushed usually is the newest, so most days the belief holds.

The half-truth: latest is the most recently pushed image with that name, by whoever pushed it. Being the newest version is a habit of some pipelines, not a rule of Docker or the registry.

What actually happens

A tag is a name that can move

An is a label on an image in a repository. Docker's best-practices guide is direct about it: "Image tags are mutable, meaning a publisher can update a tag to point to a new image." A push to shop-api:latest moves the name to the pushed image. Nothing compares version numbers or dates first. The same guide describes publishers moving tags like 3.21 to newer patch releases and adds that "most publishers use this tagging strategy, but it isn't enforced."

A digest is the image's fingerprint

An identifies the content itself. The Kubernetes docs explain the difference in two sentences: "Digests are hashes of the image's content, and are immutable. Tags can be moved to point to different images, but digests are fixed." It's a SHA-256 , so any change to the image gives a new digest. Docker shows it on every push and pull, and the docker image pull reference says that when pulling by digest, "you specify exactly which version of an image to pull."

Each machine resolves the tag when it pulls

A tag is turned into an image when a machine pulls it, not when you deploy. And docker run doesn't pull an image it already has: its default pull policy, missing, means "Pull the image if it was not found in the image cache, or use the cached image otherwise." A server that pulled latest last week keeps running last week's image. A new server pulls whatever latest is now. The Kubernetes docs warn about the result: "you might end up with a mix of Pods running the old and new code."

The fix: deploy the digest, not the name

We reproduced the hook with Docker 29.4.3 and a local registry:3.1.2 on port 5055. Version 1.4.0 was pushed as 1.4.0 and latest; then the 1.3 hotfix was pushed as 1.3.1 and, like in the hook, as latest. To play a server that had pulled latest before the hotfix, we pointed its local latest tag back at 1.4.0:

Bash terminal
# The 1.3 hotfix pipeline also moves latestdocker tag localhost:5055/shop-api:1.3.1 localhost:5055/shop-api:latestdocker push localhost:5055/shop-api:latest# latest: digest: sha256:fdcd194b8298db4352335e4833b2febb6af2cff72f71341a0ff369b15897dc54 size: 668# A server that pulled latest before that pushdocker run --rm localhost:5055/shop-api:latest# shop-api 1.4.0# A server that pulls nowdocker run --rm --pull=always localhost:5055/shop-api:latest# shop-api 1.3.1

In the first tab, one name gave two answers. The hotfix moved latest from 1.4.0's digest to 1.3.1's: the newest push, not the newest version. The server with a cached copy ran 1.4.0 without asking the registry, and the server that pulled got 1.3.1. In the second tab, the pull ran on a machine with no copy of the image, after latest had already moved. It still got 1.4.0, because the digest names the content, and that content can't change.

ReferenceCan it change?Use it for
shop-api (no tag)Yes, it means shop-api:latestLocal experiments
shop-api:latestYes, with every push of that nameNothing you deploy
shop-api:1.4.0By convention no, but the registry allows itRelease notes, humans
shop-api@sha256:f243…No, it's the hash of the contentDeploys, rollbacks, audits
shop-api:1.4.0@sha256:f243…No, only the digest is used to pullReadable and pinned

How to apply it in your project

  1. Stop deploying latestSearch your deploy scripts, Compose files and manifests for :latest and for images with no tag at all. The Kubernetes docs say to avoid it in production because "it is harder to track which version of the image is running and more difficult to roll back properly."
  2. Tag every build with something uniqueUse the release version or the commit SHA, and never push the same tag twice. Treat a reused tag as a bug in the pipeline.
  3. Record the digest and deploy itSave the digest that docker push prints with the build, and pass image@digest to the deploy step. A rollback then means deploying the previous digest, which still points at exactly what ran before.
  4. Pin base images tooWrite FROM lines as tag@digest and let a bot open pull requests when the publisher moves the tag. Your builds stop changing under you, and the updates stay visible.

Key takeaways

  • latest is the default tag name, not a version: it points to whatever was last pushed with that name.
  • Tags are mutable; a digest is the hash of the image's content and can't move.
  • Each machine resolves a tag when it pulls, and docker run reuses a cached image by default, so one tag can mean different images on different servers.
  • Deploy by digest, ideally written as tag@digest, and roll back to the previous digest.
  • Pinned digests skip security updates, so update them on purpose through your pipeline.

📚 المصادر

  1. docker image tag — Docker Docs
  2. docker image pull — Docker Docs
  3. docker container run — Docker Docs
  4. Building best practices — Docker Docs
  5. Images — Kubernetes

التعليقات (0)