43

I have been following the Docker tutorial here, and built a test image on my local OSX machine by committing changes to an existing image and tagging it with three different labels:

# docker images
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
adamatan/sinatra         devel               fccb6b4d21b4        8 minutes ago       469.5 MB
adamatan/sinatra         junk                fccb6b4d21b4        8 minutes ago       469.5 MB
adamatan/sinatra         latest              fccb6b4d21b4        8 minutes ago       469.5 MB

However, none of these images has a digest:

# docker images --digests adamatan/sinatra
REPOSITORY          TAG                 DIGEST              IMAGE ID            CREATED             SIZE
adamatan/sinatra    devel               <none>              fccb6b4d21b4        9 minutes ago       469.5 MB
adamatan/sinatra    junk                <none>              fccb6b4d21b4        9 minutes ago       469.5 MB
adamatan/sinatra    latest              <none>              fccb6b4d21b4        9 minutes ago       469.5 MB

Other test images I have created with a Dockerfile do have a digest.

Why do some images have a digest and some don't? Is it related to the way the images were created (Dockerfile or not)?

Adam Matan
  • 128,757
  • 147
  • 397
  • 562

3 Answers3

43

Firstly, Please keep in mind that a digest could represent a manifest, a layer or a combination of them (we normally called that combination an image).

Manifest is a new term that introduced with Docker registry V2. Here is a short description fetched from Docker Registry V2 slides page21 ~ page23:

  • [Manifest] describes the components of an image in a single object
    • Layers can be fetched immediately, in parallel.

When you get the digests with command docker images --digests, here the digest is the SHA256 hash of image manifest, but image ID is the hash code of the local image JSON configuration (this configuration is different from manifest). In this case, if an image doesn't have an associated manifest, the digest of that image will be "none".

Normally, two scenarios could make an image doesn't have associated manifest:

  1. This image has not been pushed to or pulled from a V2 registry.
  2. This image has been pulled from a V1 registry.

To generate a manifest, the easiest way is to push the image to a V2 registry (V1 registry will not works). Docker client will generate a manifest locally, then push it with image layers to registry. When you pull the image back, the image will has a manifest.

Once the manifest existing, your image digest should not be "none".

tshepang
  • 12,111
  • 21
  • 91
  • 136
Haoming Zhang
  • 2,672
  • 2
  • 28
  • 32
  • 2
    There's a new 'experimental' `docker manifest` command - but it still doesn't quite do what the user would actually want, ie. generate the manifest locally for an image which is missing one. – Ed Randall Feb 26 '20 at 16:33
5

Yes it is related to how the images were created. Docker can be a real stinker at times.

This may be helpful for you in this case.

Colin
  • 865
  • 1
  • 6
  • 23
  • 3
    It's crazy - `docker inspect ` will print the digest, even though `docker images --digests` prints ``. – Ed Randall Feb 26 '20 at 16:25
  • 1
    Yea. Not sure what to think of it. Bug? Intentional design? Docker is complex if you think about it. I’d stick my hand on a bug. Will submit to them. – Colin Jul 02 '20 at 01:19
  • 2
    @EdRandall thank you for this. I was going crazy with an un-related skaffold issue, this has helped a lot. – Eugene Jun 30 '21 at 15:10
  • 4
    FWIW and in contrast to @EdRandall above, I **don't** find `docker inspect` to have a digest if `docker images ---digest` shows ``. Granted, I'm writing this in 2022, with Docker engine version 20.10.17. Things could have changed, but I clarify this for later readers. More specifically, I find that the `inspect` shows the array `RepoDigests` to be empty when there is no digest, otherwise there's a value. – charlie arehart Aug 28 '22 at 16:04
-2

I was also facing this issue (digest was none).

Reason was when I can the docker image and image was listed in docker images.

At this point, I was checking for the digest value using

docker images --digest

and the digest value comes as <none>.

Resolution:

Push the image in your docker repository, then image will show the digest value.

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
ajay
  • 41
  • 5