Searching docker hub registry images/layers by their SHA digest
Asked Answered
B

1

13

If you ever attentively browse for docker images on https://hub.docker.com you may have once dissect all the commands composing an image of interest within a certain tag.

Great, but then you may have seen this kind of "translated" command when you click on a specific line of a command:

A Docker file FROM... somewhere

I may be wrong here because I'm not a Docker expert, but this seems to be an SHA-256 digest which refers to... something else inside the Hub.

My question is; how to find what exactly does it refer to, knowing the SHA value (3a7bff4e139bcacc5831fd70a035c130a91b5da001dd91c08b2acd635c7064e8)?

Beeves answered 16/12, 2020 at 19:51 Comment(1)
Do you have an example of a image with that layer?Fiji
T
3

The SHA value you see is the digest of the file that was added.

For example, suppose you have the following dockerfile:

FROM scratch
ADD foo.txt /foo.txt

If you were to push that to dockerhub, you would see something like:

ADD file:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c in /

where b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c is the digest of foo.txt.

There's no definitive way to reverse this information to obtain the file, considering ADD can do things like unpack tar archives.

With modern versions of Docker/buildkit, you might see the filename instead.

This is the same thing you see when using docker image history.

Toxicosis answered 17/7, 2021 at 0:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.