brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: crane digest prints the digest of an image tag straight from the registry

Images and volumes
~/tips/tip-crane-digest

crane digest nginx:latest

Prints the sha256 digest of an image as the registry has it, so you can pin it.

A tag like latest can point at something new tomorrow. A digest cannot. I like crane, a small tool from the go-containerregistry project, for getting that digest without pulling the image.

crane digest nginx:latest

It asks the registry and prints the digest of the image, a sha256: string. With --full-ref it prints the whole reference with the digest in it, ready to paste:

crane digest --full-ref nginx:latest

That output is what you put in a Compose file or a Kubernetes manifest after the image name, written as image: name@sha256:.... The image then stays exactly the one you looked at, even if the tag moves.

There is also a --platform flag in the form os/arch, such as linux/amd64. The docs say it defaults to all platforms. For a multi-arch image I’d run the command both ways and compare, so I know whether I am pinning the whole multi-arch image or one architecture.

The caveat is the pin itself. A pinned digest never updates, so a security fix in the base image will not reach you until you look up the new digest on purpose.

Further reading: crane digest

More Images and volumes tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker build -t myimage:latest – <<EOF All Images and volumes tips (32) All topics

Link