I am trying to search for an image using it's SHA256 hash:
I have sha256 hash and I want to know if any docker image with this sha256 hash exists or not. Is it possible to do that and how?
I am trying to search for an image using it's SHA256 hash:
I have sha256 hash and I want to know if any docker image with this sha256 hash exists or not. Is it possible to do that and how?
You could list all the images with docker images
and find a particular one:
docker images --no-trunc -q | grep <image_hash>
Or you want to search via a chunk of hash number:
docker images -q | grep <image_hash>
Here is the easiest way I know using the Docker registry API. If I have an existing Docker repo on the local network, I can query whether a specific image exists there using the SHA hash. Just need to make a simple HTTP GET request. Assemble the string like this -
FullURL = DomainAndPort + "/v2/" + imageName + "/blobs/sha256:" + imageHash;
An example request that works for me on our network repo -
http://10.10.9.84:5000/v2/hello-world/blobs/sha256:8089101ead9ce9b8c68d6859995c98108e1022c23beaa55754acb89d66fd3381
Entering that string into a Chrome browser returns a JSON object describing the image. If you enter an invalid sha256 hash then the API returns -
{"errors":[{"code":"DIGEST_INVALID","message":"provided digest did not match uploaded content","detail":{}}]}
For more details see "Pulling a Layer" in https://docs.docker.com/registry/spec/api/
© 2022 - 2024 — McMap. All rights reserved.