Docker Community Forums

Share and learn in the Docker community.

Get image digest from remote registry via API


(Dwake) #1

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 github.com/docker/distribution/commit/e430d773428

Thanks.

EDIT: I’ve found the fix here: https://github.com/docker/distribution/issues/1565

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”


(Jerry Baker) #2