Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find docker image for a container?

I am trying to find the corresponding docker image for a container.

docker inspect <container-id> 

This gives a whole lot of information. It also gives the docker image if I do : docker inspect ['Config']['Image']

But this is not the reliable source as some times it just gives some SHA, something like sha256:00954e990edd7c78dff64c8031c58c07cb36b4591dca3923b5a1a1c31199e54c

Is there a reliable way to find the docker image for a container?

Especially through Python code.

I have docker client but that doesn't support any query that can give me Image name.

like image 572
Mohammed Avatar asked Dec 12 '25 01:12

Mohammed


1 Answers

docker inspect <container-id> gives you the Image property, as you've noticed:

"Image": "sha256:8d6721e9290e96cc34faeee7a525311a400598e7fee170190c73ce103dd621ce"

You can use that hash value to subsequently inspect the image itself: docker inspect <image-id>. In the example above "8d6721e9290e96cc34faeee7a525311a400598e7fee170190c73ce103dd621ce" is the image ID.

like image 167
mustaccio Avatar answered Dec 14 '25 14:12

mustaccio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!