Container Image Version Pinning vs Mutable Tags

Docker

An image tag is a pointer the publisher can move. :latest moves on every release; a release tag such as elestio/pgadmin:REL-9_18 usually stays put, but nothing forces it to. Only a digest (@sha256:…) names one exact image. Pinning makes deployments deterministic, at the cost of having to update on purpose.

Risks of :latest

  1. Unplanned upgrades: docker compose pull or a rebuild can bring in a new major version with breaking configuration changes, or one that no longer works with the data in a persistent volume (such as /var/lib/pgadmin in pgadmin_data).
  2. Drift between environments: two hosts with the same docker-compose.yml, pulled on different days, run different images.
  3. No record of what changed: the version that runs in production changes without any commit in Git.

Tags vs Digests

A release tag fixes risks 1–3 as long as the publisher doesn't move it. It does not protect against a compromised publisher: an attacker with the account can re-push REL-9_18 as easily as :latest. To be sure you run the image you reviewed, pin the digest as well:

services:
  pgadmin4:
    # Avoid: image: elestio/pgadmin:latest
    image: elestio/pgadmin:REL-9_18@sha256:<digest>

With tag@digest, Docker pulls by digest and the tag is only a label for humans. Get the digest with docker buildx imagetools inspect elestio/pgadmin:REL-9_18, or from the image a host already runs (see the SSH tunneling how-to).

The Cost: Updates Become Your Job

A pinned image no longer picks up security fixes. Pinning only works with an update process:

  • A bot (Renovate, Dependabot) opens a pull request when a new tag or digest is published.
  • The bump is tested against a copy of the persistent volumes before it reaches production.
  • The same tag@digest is then promoted unchanged from staging to production.

References

Review cards

Flashcard Why is `:latest` risky in a Compose file?

The tag moves on every release, so the next pull or rebuild can bring in a breaking major version, with no commit in Git to show it.

Flashcard Why is a release tag safer than `:latest` but still not fully reliable?

It normally stays on one image, so no surprise upgrades, but it's still a pointer the publisher can move.

Flashcard Why pin a digest even when you already pin a release tag?

Anyone with the publisher's account can re-push the tag with different content. A digest names one exact image, so you run the one you reviewed.

Flashcard What is the cost of pinning images, and how do you handle it?

Pinned images no longer pick up security fixes, so you need an update process: a bot such as Renovate opens PRs for new versions, which are tested before promotion.

Quiz With `image: elestio/pgadmin:REL-9_18@sha256:<digest>`, what does Docker pull?
  • The image matching the digest; the tag is only a label
  • Whatever REL-9_18 currently points to
  • Whichever of the two was pushed most recently
  • Nothing: a tag and a digest together are invalid

With tag@digest, Docker pulls by digest and ignores where the tag points.