When we run a docker container if the relevant image is not in the local repo it is being downloaded but in a specific sequence i.e parent images etc.
If I don’t know anything about the image how could I find from which images is being based on based on the layers pulled as displayed in a docker run
?
The output only shows the SHA1s on any docker run etc

- 3,845
- 3
- 22
- 47
2 Answers
AFAIK, you can't, there is no reverse function for a hash.
Docker just tries to get the image from local, when its not available tries to fetch it from the registry. The default registry is DockerHub.
When you don't specify any tag when running the container ie: docker run ubuntu
instead of docker run ubuntu:16.04
the default latest
is used. You'll have to visit the registry and search which version the latest
tag is pointing to.
Usually in DockerHub there is a link pointing the GitHub repo where you can find the Dockerfile, in the Dockerfile you can find how its built, including the root image.
You also can get some extra info with docker image inspect image:tag
, but you'll find more hashes in the layers.

- 1,347
- 11
- 23
-
I am interested in the ones that the image is based on and is downloaded before the one I actually called run for – Jim Jan 14 '19 at 12:23
-
You could take a look at https://imagelayers.io/ but I think is pretty buggy atm (not working properly with DockerHub) and only shows the commands applied, not the `from` image. In the actual image you can only see the number of layers and their hash, nothing else. So, the only reliable way I can think of is through the Dockerfile. – Cristian Todea Jan 14 '19 at 12:31
Take a look to dockerfile-from-image
"Similar to how the docker history command works, the dockerfile-from-image script is able to re-create the Dockerfile (approximately) that was used to generate an image using the metadata that Docker stores alongside each image layer."
With this, maybe you can get the source of the image.

- 312
- 3
- 14