Guides / Containers

Keep Docker images updated: tags, digests, rebuilds and Renovate

beginnerUpdated 26 Nov 20261012 words

A container image is a frozen copy of a file system. The OpenSSL, glibc and Python inside it stay at the version they had on the day of the build. Unattended upgrades on the host do not reach them, and restarting the container does not either. An image gets security fixes only when someone builds a new one and you start containers from it. Both the images you build and the ones you pull need a routine for that.

Tags, digests and what they promise

An image reference has a name, a tag and optionally a digest:

Reference What you get
nginx or nginx:latest whatever the publisher tagged last; can be a new major version
postgres:17 the latest 17.x; minor updates arrive on the next pull
postgres:17.11-alpine3.24 one version of PostgreSQL on one Alpine branch; the publisher can still rebuild it under the same tag
debian:bookworm-20261027-slim a dated build of Debian 12; later builds get a new date
alpine:3.24@sha256:… one image, verified by its hash; the tag is only a label for people

Tags are mutable. The publisher can point them at a new image at any time. A digest cannot change. This has two consequences.

  • Avoid latest and bare major tags for anything that runs in production. You do not control when a new major version arrives, and you cannot tell from the compose file what runs.
  • A pinned tag or digest keeps the image stable, which also means it stays old. Pinning only works together with a process that bumps the pins: a tool that opens pull requests, or a calendar entry.

To see the digest of an image you run:

docker image inspect --format '{{index .RepoDigests 0}}' postgres:17.11-alpine3.24

Rebuild your own images on a schedule

A Dockerfile like this one gets security fixes from two places, the base image and the packages it installs:

FROM debian:bookworm-slim
RUN apt-get update \
 && apt-get install -y --no-install-recommends ca-certificates curl \
 && rm -rf /var/lib/apt/lists/*

docker build caches both. Without options it reuses the base image already on the build host and the RUN layer from the last build, so a rebuild can produce the same old packages. Force both to refresh:

docker build --pull --no-cache -t example/app:2026-11-26 .

--pull checks the registry for a newer version of the base tag. --no-cache runs every step again, so apt-get install fetches the current packages.

Do this on a schedule, not only when the code changes, for example in a weekly CI job that rebuilds, scans and pushes. In GitHub Actions, a schedule trigger next to push does it:

on:
  push:
    branches: [main]
  schedule:
    - cron: "17 4 * * 1"   # Mondays 04:17 UTC

Then redeploy, since a new image in the registry does not change running containers.

Update images you pull

For third-party images in a compose file, updating means pulling and recreating:

docker compose pull
docker compose up -d
docker image prune

docker compose up -d recreates the containers whose image or configuration changed and leaves the others running. docker image prune removes dangling images, those without a tag, that are left over.

With a floating tag such as postgres:17, docker compose pull brings minor updates. With exact versions, you edit the version in the compose file first. Read the release notes of databases and other stateful services before a major version: PostgreSQL 16 to 17, for example, needs a dump and restore or pg_upgrade, and a new container on the old data directory refuses to start.

Tools exist that pull and restart containers automatically. They skip the review step, so a broken release reaches production unattended. For a hobby server that may be acceptable; for anything with data, prefer pull requests that you merge.

Let Renovate or Dependabot open the pull requests

Both read FROM lines and compose files and propose version bumps as pull requests.

Renovate recommends pinning digests. With the docker:pinDigests preset it adds a digest to every image reference and opens a pull request whenever the image behind the tag changes:

{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "extends": ["config:recommended", "docker:pinDigests"]
}

The result is a line such as FROM node:24.21.0-alpine3.23@sha256:… that Renovate keeps current. Add default:automergeDigest if you want digest-only updates merged when the tests pass.

Dependabot on GitHub handles Dockerfiles with the ecosystem docker and compose files with docker-compose, in .github/dependabot.yml:

version: 2
updates:
  - package-ecosystem: "docker"
    directory: "/"
    schedule:
      interval: "weekly"
  - package-ecosystem: "docker-compose"
    directory: "/"
    schedule:
      interval: "weekly"

Dependabot does version updates for these ecosystems; its security updates (the alerts with automatic pull requests) do not cover them, according to the GitHub documentation.

Know what you run

Over time, servers collect containers that nobody remembers. List the image and the creation date of each:

docker ps --format '{{.Names}}\t{{.Image}}' | while IFS="$(printf '\t')" read -r name image; do
  printf '%s\t%s\t%s\n' "$name" "$image" "$(docker image inspect --format '{{.Created}}' "$image")"
done

An image that is months old has usually missed fixes. A scanner tells you which:

trivy image --severity HIGH,CRITICAL --ignore-unfixed postgres:17.11-alpine3.24

--ignore-unfixed hides findings without a fixed version, so the list shows what a rebuild or a newer tag would fix. Scan images in CI runs the same check before an image ships.

End of life of the base

Pinning alpine:3.20 gets you rebuilt images with fixes until the branch ends, then nothing. Plan a bump of the base release at least once a year; the dates are in End-of-life dates of Linux releases.

Patchbrief scans the image of every running container each day and lists fixable vulnerabilities with the image that needs a rebuild or a newer tag.

Sources

Check your servers every day

The agent of Patchbrief reports the packages and settings of a server once a day; the digest names what to fix first.

Start free