Pinning a docker image to a specific nightly snapshot

the docker images, like swift:nightly update automatically with the most recent nightly snapshot.

but because i work with the swift-syntax library, i need images that are pinned to specific nightlies, such as DEVELOPMENT-SNAPSHOT-2022-12-17-a.

are there docker images for specific nightlies, such as DEVELOPMENT-SNAPSHOT-2022-12-17-a, as opposed to whatever the most recent nightly happens to be?

If you have the image you want to pin to cached locally, you can pin to its image digest (the sha256 digest id, not the id listed via docker image ls). You can find it via inspect:

❯ docker image inspect swiftlang/swift:nightly-5.7-focal | jq .[].RepoDigests[0]
❯ docker pull swiftlang/swift@sha256:5f1e4a51dc83fc8b1479dc46568c288c91c94a0da8c21f7b9f7c5f2c958c636d Pulling from swiftlang/swift
Digest: sha256:5f1e4a51dc83fc8b1479dc46568c288c91c94a0da8c21f7b9f7c5f2c958c636d
Status: Image is up to date for swiftlang/swift@sha256:5f1e4a51dc83fc8b1479dc46568c288c91c94a0da8c21f7b9f7c5f2c958c636d

The same syntax works in the FROM clause in a Dockerfile - or anywhere you can use docker tags, I believe.

1 Like

is there a way to search historically for specific snapshots?

I can't see any historical digests on Docker Hub and it doesn't seem to be possible to query for it:

Your best shot might be to get it from the logs of the CI job that creates the build. I would imagine docker push logs the digest somewhere after pushing the image?

1 Like