Safeguard
Developer Tools•

Pin a Docker base image by tag or digest: which keeps you patched?

Tags are mutable and digests are fixed. Compare both for patching, see why build pull matters and how Dependabot raises base image update pull requests.

Safeguard Security Team
3 min read

A digest gives you reproducible builds but no automatic fixes. A tag gives you fixes you did not choose and cannot easily audit. The best pattern is a digest plus an update bot, so each base image change arrives as a reviewable pull request. Docker's own build guidance supports that approach.

How tags and digests differ

Docker's best practices page says image tags are mutable, meaning a publisher can update a tag to point to a new image. A tag like 3.21 can resolve to different builds over time.

A digest locks the exact image. The page says you are guaranteed to always use the same image version, even if a publisher replaces the tag. The tradeoff it names: digest pinning is tedious by hand, and you opt out of automated security fixes, which you probably want.

ApproachReproducibleGets fixes on rebuildAudit trail
Floating tagNoYes, silentlyWeak
Digest onlyYesNoClear but stale
Digest plus update botYesYes, via pull requestClear

Images are snapshots

The guidance says to rebuild images regularly with updated dependencies to keep them current. It recommends the pull flag on docker build, which forces a check for a newer base image, and the no-cache flag to refresh package manager dependencies. The two do different jobs, and the page says they can be combined.

docker build --pull --no-cache -t myapp:dev .

Without pull, a cached older base image can be reused even when a newer one exists. That is a common reason a rebuild does not pick up a fix.

Let a bot do the tedious part

The page recommends Dependabot with the docker package ecosystem, which raises pull requests to update base image tags and digests on a schedule. The stated benefit is control and an audit trail of when and how the change occurred, as opposed to silent changes from a floating tag.

Dependabot also lists dev containers, Docker Compose and Helm among its supported ecosystems, which covers many developer tooling images.

A simple policy

  1. Pin production and CI base images by digest.
  2. Enable Dependabot version updates for docker, weekly.
  3. Rebuild and redeploy at least monthly even when nothing changed upstream in your code.
  4. Scan the built image, not only the Dockerfile.
  5. Record which base image digest each deployment used.

Note that tooling images used inside pipelines, such as the one holding your linters and CLIs, need the same treatment as application images. They often get none.

Safeguard scans container images and ties findings back to the base layers. Try it free at gold.safeguard.sh/scan.

Try it yourself

Click through it at your own pace, or open it full screen.

Open an image result and see which findings come from the base image rather than your own layers.

Quick check

Why did my rebuild not pick up a patched base image?

A cached base image may be reused. Use the pull flag so Docker checks for a newer version.

Does pinning by digest stop security fixes?

It stops them arriving automatically. Docker notes you opt out of automated fixes, so pair it with an update bot.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.