Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 there's 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?

like image 765
christian Avatar asked Oct 19 '22 16:10

christian


People also ask

Where can I find docker image Sha?

The Docker image digest SHA is a critical piece of evidence that makes a container and the content unique. You get the Docker image digest SHA from an image stored in a docker registry. Easy to do if the image has been pulled, just run docker image ls <image> –digests.

How can I get Sha ID image?

You can find the SHA by either pulling the image (it shows the digest once the image is pulled) or by inspecting the image.

Can I get source code from docker image?

Hi, if you write a compiled application (C, C++, go, …), the source code will not be part of the docker image, and they cannot access source code. But if you are using python, PHP, shell, for sure, if they get your docker image, they can access everything.


Video Answer


2 Answers

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.

like image 156
Michael Barton Avatar answered Oct 22 '22 04:10

Michael Barton


You can get it by docker images --digests

REPOSITORY          TAG    DIGEST                                                                    IMAGE ID     CREATED        SIZE
docker/ucp-agent    2.1.0  sha256:a428de44a9059f31a59237a5881c2d2cffa93757d99026156e4ea544577ab7f3   583407a61900 3 weeks ago    22.3 MB
like image 151
Rajarajan Pudupatti Sundari Je Avatar answered Oct 22 '22 04:10

Rajarajan Pudupatti Sundari Je