ContainersDocker
Image tags and digests: why latest breaks deploys
A tag can be moved to point to a different image. A digest is a hash of the image content and is fixed. The Kubernetes documentation advises against the latest tag in production.

Tags move, digests do not
The Kubernetes documentation puts it in one sentence: a tag can be moved to a different image, and a digest stays fixed. A digest has two parts: the hash algorithm, for instance sha256, and the hash value.
Docker says the same from the publisher's side. Image tags are mutable: the publisher can repoint a tag at a new image. Its example is alpine:3.21, which resolves to the latest patch version of 3.21.
latest is the default tag. If a FROM instruction has no tag or digest, the builder assumes latest. If a pod's image has no tag, Kubernetes assumes latest too.
What Kubernetes does with a tag
When a pod is submitted with no imagePullPolicy, the cluster sets one from the image reference:
- a digest:
IfNotPresent - the tag
:latest, or no tag:Always - any other tag:
IfNotPresent
The value is set when the object is first created. It is not updated if the tag or digest changes later.
IfNotPresent pulls the image only when the node has no local copy of it. With Always, the container runtime contacts the registry and resolves the tag to a digest every time the kubelet launches a container.
The same page spells out the risk. When the registry points a tag at different code, some of your pods can be running the old code while others run the new. It advises against :latest in production for two reasons: tracking which image version is running gets harder, and so does a proper rollback.
Only a change to the pod template triggers a Deployment's rollout. An updated container image in the template is one such change.
Pin by digest
Docker's example for a Dockerfile keeps the tag and adds the digest:
# syntax=docker/dockerfile:1
FROM alpine:3.21@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88cIn a pod, replace <image-name>:<tag> with <image-name>@<digest>. The Kubernetes page lists this reference among its examples:
registry.k8s.io/pause@sha256:1ff6c18fbef2045af6b9c16bf034cc421a29027b800e4f9b68ae9b1cb3e9ae07A reference can carry a tag and a digest. Then only the digest is used for pulling.
Docker prints the digest of an image after a pull, and again when you push. docker buildx imagetools inspect shows the Digest of an image in a registry.
Docker also states the cost. A pinned image is pinned to a version in time, and Docker does not pull updated versions of it. To get a security update, you change the digest.
A tag scheme from commit and version
docker/metadata-action extracts metadata from Git references and GitHub events, to tag and label Docker images. This step is from an example in its README:
-
name: Docker meta
id: meta
uses: docker/metadata-action@v6
with:
images: |
name/app
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=shaThe README shows the result for a push of the Git tag v1.2.3: the tags name/app:1.2.3, name/app:1.2, name/app:sha-90dd603 and name/app:latest. name/app is the README's image name. Use your own.
type=shaoutputs the short commit SHA with the prefixsha-.type=semverrequires a valid semver Git tag.{{version}}gives1.2.3, and{{major}}.{{minor}}gives1.2.latestcomes from theflavorinput. Its default,latest=auto, generates the tag fortype=semver. The input also acceptstrueandfalse.
In the README's first example, the build step of docker/build-push-action takes the list as tags: ${{ steps.meta.outputs.tags }}. That action has an output named digest, the image digest.
Immutable tags in the registry
Amazon ECR sets tag immutability per repository. name and us-east-2 are the documentation's values:
aws ecr put-image-tag-mutability --repository-name name \
--image-tag-mutability IMMUTABLE --region us-east-2A push with a tag that is already in the repository then returns ImageTagAlreadyExistsException. The ECR page contradicts itself on one point. Its introduction says tag immutability affects all tags, and that you cannot make some tags immutable while others are not. Further down, the same page documents an IMMUTABLE_WITH_EXCLUSION setting with tag exclusion filters. Test exclusions in your own repository before you rely on them.
Google Artifact Registry has a flag for Docker repositories:
gcloud artifacts repositories update REPOSITORY \
--project=PROJECT-ID \
--location=LOCATION \
--immutable-tagsOnce the setting is on, each tag stays bound to one image digest, and that includes the default latest tag. Deleting a tagged image and removing a tag from an image are no longer permitted.
Digests that stay current
- Renovate recommends pinning Docker images to an exact digest and updates the digests for you. It keeps the tag in the
FROMline for readability, and it opens a pull request when the image behind the tag is updated. Itsdocker:pinDigestspreset pins Docker digests. - Dependabot, per Docker's best-practices page, raises pull requests to update base image tags and digests on a schedule when it is configured with
package-ecosystem: "docker".
What to check first
- Search your manifests for
:latestand for images with no tag. Kubernetes setsimagePullPolicy: Alwaysfor both. - Read
imagePullPolicyon objects that already exist. It was set at creation. - Run
kubectl describe podand read theImage IDline. In the Kubernetes documentation's sample output it holds the image with itssha256digest. - If you deploy by digest, read the registry's cleanup rules. Azure Container Registry's retention policy page warns against a retention policy for untagged manifests when systems pull images by manifest digest.
Sources
Want a second pair of eyes on yours? We do this work for a living.
More guides

Software supply chain: pin, sign and verify
Supply chain · 2 min read
Pin your actions, sign what you build and check the signature before you deploy.

Choosing a container registry: ECR, ACR, Artifact Registry, Harbor or JFrog
Containers · 4 min read
Nine things to compare, then ECR, ACR, Artifact Registry, Harbor and JFrog Artifactory side by side.

Run containers as a non-root user
Containers · 4 min read
The USER instruction, file ownership with COPY --chown, ports below 1024 and runAsNonRoot.