Where can I find the sha256 code of a docker image?

christian picture christian · Aug 17, 2015 · Viewed 75.9k times · Source

I´d like to pull the images of centos, tomcat, ... using their sha256 code, like in

docker pull myimage@sha256:0ecb2ad60

but I can´t find the sha256-code to use anywhere.

I checked the dockerhub repository for any hint of the sha256-code, but couldn't find any. I downloaded the images by their tag

docker pull tomcat:7-jre8

and checked the image with docker inspect to see if theres a sha256 code in the metadata, but there is none (adding the sha256 code of the image would probably change the sha256 code).

Do I have to compute the sha256 code of an image myself and use that?

Answer

Michael Barton picture Michael Barton · Nov 4, 2015

Latest answer

Edit suggested by OhJeez in the comments.

docker inspect --format='{{index .RepoDigests 0}}' $IMAGE

Original answer

I believe you can also get this using

docker inspect --format='{{.RepoDigests}}' $IMAGE

Works only in Docker 1.9 and if the image was originally pulled by the digest. Details are on the docker issue tracker.