(howto) Get a Docker's image digest

Geraldine_VdAuweraGeraldine_VdAuwera Cambridge, MAMember, Administrator, Broadie admin
edited March 2018 in Archive

The contents of this article have been moved to the Dictionary entry on Docker.


Getting a Docker's image digest :

Say I want to get the digest for my_repo/my_image:tag. There are two ways to get it, and in both cases I'll be looking for something that looks like sha256:something_long, where the something_long bit is the digest.

1. If the image is not on my computer

I can just do docker pull my_repo/my_image:tag and the digest will be displayed in the output as:

Digest: sha256:96bf2261d3ac54c30f38935d46f541b16af7af6ee3232806a2910cf19f9611ce

2. If it is on my computer

I can use docker inspect instead but the output is more complicated:

~ $ docker inspect my_repo/my_image:tag
[
    {
        "Id": "sha256:a98acb9802cbf46eb71e28c652f58026c027d9580ff390c6fa9ae4dec07ae13d",
        "RepoTags": [
            "my_repo/my_image:tag"
        ],
        "RepoDigests": [
            "my_repo/[email protected]:96bf2261d3ac54c30f38935d46f541b16af7af6ee3232806a2910cf19f9611ce"
        ],

...and a lot of other details we don't care about right now.

Note that in the latter case there are two things that look like sha256:something_long. The one you want is the "RepoDigests" one, not the "Id".

Then in your WDL, you write my_repo/[email protected]:something_long. Note that the tag isn't there at all, as it's been replaced by the digest, which is a more specific identifier.

Post edited by Geraldine_VdAuwera on
Tagged:
Sign In or Register to comment.