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

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


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.


You can get it by docker images --digests

REPOSITORY          TAG    DIGEST                                                                    IMAGE ID     CREATED        SIZEdocker/ucp-agent    2.1.0  sha256:a428de44a9059f31a59237a5881c2d2cffa93757d99026156e4ea544577ab7f3   583407a61900 3 weeks ago    22.3 MB


Simplest and most concise way is:

docker images --no-trunc --quiet $IMAGE

This returns only the sha256:... string and nothing else.

e.g.:

$ docker images --no-trunc --quiet debian:stretch-slimsha256:220611111e8c9bbe242e9dc1367c0fa89eef83f26203ee3f7c3764046e02b248

Edit:

NOTE: this only works for images that are local. You can docker pull $IMAGE first, if required.