Keenrig

Docker image vs container, and why to pin digests

An image is the package, a container is the running copy. How tags and digests differ, why latest is a trap, and how to pin an image by digest in practice.

People use “image” and “container” as if they were the same thing. They are not, and the difference explains most of the surprises in self-hosting: why data vanished after an update, why “the same app” behaves differently on two servers, and why reinstalling last year’s setup gives you this year’s bugs.

Image: the package

An image is a read-only bundle: a stack of filesystem layers plus metadata saying which command to run, which user to run it as, and which ports it listens on. It is built once (from a Dockerfile, usually) and pushed to a registry such as Docker Hub or GitHub Container Registry. Nothing inside an image changes after it is built.

Container: the running copy

A container is an instance of an image: the image’s layers, plus a thin writable layer on top, plus runtime settings (environment variables, mounts, network, limits) and a process. You can run many containers from one image. When a container is removed, its writable layer goes with it — which is why anything you want to keep must live in a volume or bind mount, not inside the container.

docker image ls               # images on this machine
docker ps -a                  # containers, running or stopped
docker run -d --name web nginx:1.27-alpine
docker rm -f web              # container gone; the image stays

An analogy that holds up: the image is the installer, the container is the installed program with its own settings. Updating an app in Docker means pulling a new image and replacing the container — not patching the old one.

Tags vs digests

You refer to an image in two ways. A tag is a human-readable name such as nginx:1.27-alpine or n8nio/n8n:latest. A digest is a content hash such as sha256:4ff1…, computed from the image itself.

The crucial difference: a tag is a pointer that the publisher can move at any time; a digest identifies exactly one set of bytes forever. latest is not special — it is just a tag that usually points to the newest build. Even a version tag such as 16 or 1.27 moves when the publisher ships a patch release or rebuilds for a security fix.

Why latest is a trap

  • Reproducibility: install today and again in six months and you get different software, with nothing on your server recording the change.
  • Silent upgrades: a routine docker compose pull can jump a major version and run a database migration you did not plan for.
  • Rollback: “go back to what worked” is hard when you never wrote down what worked.
  • Two servers drift: a server set up in March and one set up in June run different builds of the “same” setup.

How to pin by digest

Look up the digest of the tag you have tested, then reference both: the tag for humans, the digest for Docker. When both are present, Docker pulls by digest and ignores where the tag points now.

# find the digest of what you pulled
docker image inspect --format "{{index .RepoDigests 0}}" nginx:1.27-alpine

# use it in compose.yaml
image: nginx:1.27-alpine@sha256:<digest>

One caveat: multi-architecture images have an index digest that covers all platforms and per-platform digests underneath. Pin the index digest (the one docker image inspect shows in RepoDigests) so the same line works on both amd64 and arm64 machines.

Pinning moves updates from “whenever the tag moves” to “when you decide”. That is the point — but it means you must actually update, or a pinned image slowly collects known vulnerabilities. Tools such as Renovate can open a change when a new digest appears, so the decision stays yours without being forgotten.

Layers and disk space

Images are built from layers, and layers are shared. Two images based on the same Alpine or Debian base store that base once. That is why pulling a second app is often faster than the first, and why adding up the sizes docker image ls shows for each image overstates the total.

Old images do pile up, though: every update leaves the previous image behind until you remove it. Check and clean up with:

docker system df            # space used by images, containers, volumes, build cache
docker image prune          # remove dangling images (no tag, unused)
docker image prune -a       # remove every image not used by a container

Be careful with the last one on a server where some apps are stopped on purpose: their images count as unused, and you will download them again on the next start. Never add --volumes to a prune command unless you mean to delete data.

How Keenrig does it

Every manifest in the Keenrig catalog carries both a tag and a digest, and only the digest is used to pull. The catalog itself is signed with Ed25519, and each server verifies the signature with a key built into the binary before trusting any entry. So the n8n you install is the exact build that was reviewed, and a reinstall a year later gives you the same bytes.

{
  "id": "nginx",
  "repository": "docker.io/library/nginx",
  "tag": "1.27.4-alpine",
  "digest": "sha256:4ff102c5d78d254a…"
}

App data lives outside the container, in a directory per app on the server, so replacing the container for a new version does not touch it. The Nginx app in the catalog is a light way to try this: it starts in under a second and its default page says plainly that it is running.

Limits

  • Pinning guarantees you get the image that was pinned, not that the image is free of vulnerabilities. Updates still matter.
  • In Keenrig, new app versions arrive through catalog updates; you do not choose arbitrary tags for catalog apps.
  • A digest says nothing about who built the image. Signatures on the image itself (for example with Sigstore cosign) are a separate layer; Keenrig signs its catalog, not the upstream images.