Get image digest from remote registry via API

Is there any way to get the digest of an image from a remote registry without actually pulling it? I’ve tried using

  • HEAD on the manifests API
  • GET on the manifests API

but neither seems to return the correct digest.

Here’s an example:

docker pull registry-server:5000/good_image:latest
latest: Pulling from good_image
Digest: sha256:ca4626b691f57d16ce1576231e4a2e2135554d32e13a85dcff380d51fdd13f6a
Status: Image is up to date for registry-server:5000/good_image:latest

In this case, ca4626b691f57d16ce1576231e4a2e2135554d32e13a85dcff380d51fdd13f6a is the digest that I want. But if I use the registry API instead of docker pull, it doesn’t return the correct digest:

curl -X GET -vvv -k http://registry-server:5000/v2/good_image/manifests/latest 2&>1 | grep ca4626b
[no output]

curl -X HEAD -vvv -k http://registry-server:5000/v2/good_image/manifests/latest 2&>1 | grep ca4626b
[no output]

Is there any way to get the desired digest? I’m using a registry built from commit Merge pull request #1482 from stweil/master · distribution/distribution@e430d77 · GitHub

Thanks.

EDIT: I’ve found the fix here: Docker-Content-Digest in GET does not match `docker push` · Issue #1565 · distribution/distribution · GitHub

I need to add “Accept: application/vnd.docker.distribution.manifest.v2+json” as an HTTP header:

curl -H “Accept: application/vnd.docker.distribution.manifest.v2+json” -X GET -vvv -k http://registry-server:5000/v2/good_image/manifests/latest 2>&1 | grep ca4626b
< Docker-Content-Digest: sha256:ca4626b691f57d16ce1576231e4a2e2135554d32e13a85dcff380d51fdd13f6a
< Etag: “sha256:ca4626b691f57d16ce1576231e4a2e2135554d32e13a85dcff380d51fdd13f6a”

3 Likes