如何使用给定的Docker映像ID查找Docker映像名称?

时间:2018-08-17 14:39:57

标签: docker dockerhub

假设我有以下映像ID,这些映像ID是从 docker hub (不是从本地计算机)提取的:

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

如何使用给定的Docker映像ID找到Docker映像名称?或如何找到上面每个图像ID的实际网址?

请注意,这些是在安装Prometheus映像(使用docker run prom/prometheus:v2.1.0命令)时需要提取的映像ID

3 个答案:

答案 0 :(得分:1)

我认为您缺少了一些东西

您共享的哈希表示图像的不同层。我假设这是特定图像的docker pull命令的输出

要了解刚刚拉出的图像,可以运行“ docker history [image_id]”,然后所有不同的层以及创建它们的命令都将显示

答案 1 :(得分:0)

我相信您正在寻找的是unix中的经典grep命令,这可以轻松解决您的问题: docker images | grep "xxxxxxxxxx"

干杯,祝你好运。

答案 2 :(得分:0)

由于最终目标是将注册表列入白名单,因此您可以将docker守护进程放入debug mode中,并查看用于获取映像的URL。

我下载centos图像时的示例:

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"

对于docker.io,您需要使用 registry-1.docker.io 允许流量。我不确定您是否可以限制每个图像。限制映像的最佳解决方案是安装维护自己的docker映像注册表。