Michel Gokan Khan
Michel Gokan Khan

Reputation: 2625

How to find docker image name using given docker image ID?

Assume I have follwoing image IDs which pulled from docker hub (not from my local computer):

aab39f0bc16d: Pull complete 
a3ed95caeb02: Pull complete 
2cd9e239cea6: Pull complete 
48afad9e6cdd: Pull complete 
8fb7aa0e1c16: Pull complete 
3b9d4fd63760: Pull complete 
57a87cf4a659: Pull complete 
9a31588e38ae: Pull complete 
7a0ac0080f04: Pull complete 
659e24e6d37f: Pull complete

How can I find the docker image name using given docker image IDs? or How can I find the actual URL of each Image ID above?

Note that these are image IDs that needs to be pulled when installing prometheus image (using docker run prom/prometheus:v2.1.0 command)

Upvotes: 3

Views: 10243

Answers (3)

gmolaire
gmolaire

Reputation: 1121

Since your end goal is to whitelist a registry, you can put the docker daemon in debug mode and watch the URLs used to get your image.

Example when I am downloading a centos image:

Aug 17 18:20:52 docker-machine: time="2018-08-17T18:20:52.690796940Z" level=debug msg="Calling POST /v1.24/images/create?fromImage=centos&tag=latest"
Aug 17 18:20:52 docker-machine: time="2018-08-17T18:20:52.691017261Z" level=info msg="{Action=create, Username=root, LoginUID=0, PID=32207}"
Aug 17 18:20:52 docker-machine: time="2018-08-17T18:20:52.691136349Z" level=debug msg="AuthZ request using plugin rhel-push-plugin"
Aug 17 18:20:52 docker-machine: time="2018-08-17T18:20:52.691681999Z" level=debug msg="Trying to pull docker.io/centos from https://registry-1.docker.io v2"
Aug 17 18:20:53 docker-machine: time="2018-08-17T18:20:53.129828996Z" level=debug msg="Using registries.d directory /etc/containers/registries.d for sigstore configuration"
Aug 17 18:20:53 docker-machine: time="2018-08-17T18:20:53.130051903Z" level=debug msg=" Using \"default-docker\" configuration"
Aug 17 18:20:53 docker-machine: time="2018-08-17T18:20:53.130065315Z" level=debug msg=" No signature storage configuration found for docker.io/library/centos:latest"
Aug 17 18:20:53 docker-machine: time="2018-08-17T18:20:53.130085358Z" level=debug msg="GET https://registry-1.docker.io/v2/"
Aug 17 18:20:53 docker-machine: time="2018-08-17T18:20:53.567233864Z" level=debug msg="Ping https://registry-1.docker.io/v2/ err <nil>"
Aug 17 18:20:53 docker-machine: time="2018-08-17T18:20:53.567270835Z" level=debug msg="Ping https://registry-1.docker.io/v2/ status 401"
Aug 17 18:20:54 docker-machine: time="2018-08-17T18:20:54.037436399Z" level=debug msg="GET https://registry-1.docker.io/v2/library/centos/manifests/latest"
Aug 17 18:20:54 docker-machine: time="2018-08-17T18:20:54.545501066Z" level=debug msg="GET https://registry-1.docker.io/v2/library/centos/manifests/sha256:fc2476ccae2a5186313f2d1dadb4a969d6d2d4c6b23fa98b6c7b0a1faad67685"
Aug 17 18:20:55 docker-machine: time="2018-08-17T18:20:55.008282140Z" level=debug msg="IsRunningImageAllowed for image docker:docker.io/library/centos:latest"
Aug 17 18:20:55 docker-machine: time="2018-08-17T18:20:55.008320868Z" level=debug msg=" Using default policy section"
Aug 17 18:20:55 docker-machine: time="2018-08-17T18:20:55.008329393Z" level=debug msg=" Requirement 0: allowed"
Aug 17 18:20:55 docker-machine: time="2018-08-17T18:20:55.008333896Z" level=debug msg="Overall: allowed"

In the case of docker.io, you will need to allow traffic with registry-1.docker.io. I am not sure you can restrict per image though. The best solution to restrict for images is to install an maintain your own docker image registry.

Upvotes: 0

gCoh
gCoh

Reputation: 3089

I think you are missing something

The hashs that you shared are representing different layers of an image. I'm assuming that this is the output of a docker pull command of a specific image

To get to know the image you just pulled, you can run 'docker history [image_id]', then all the different layers and the commands created them will show up

Upvotes: 1

bretanac93
bretanac93

Reputation: 627

I believe what you are looking for is the classic grep command in unix, this can easily solve you the problem: docker images | grep "xxxxxxxxxx"

Cheers and good luck.

Upvotes: 1

Related Questions