如何基于image_id查找(最近的)标签 [英] How to find (closest) tag based on image_id

查看:56
本文介绍了如何基于image_id查找(最近的)标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有image_id fc251f2434a12eaf8370dee1bc56ab1857978cb769d64e29fea373db699823c6 和图像名称 注册表code> ,我想为此找到最接近的标签.

I have image_id fc251f2434a12eaf8370dee1bc56ab1857978cb769d64e29fea373db699823c6 and image name registry and I want to find closest tag for that.

我尝试查询

curl https://registry.hub.docker.com///v1/repositories/registry/tags

,但没有以该哈希开头的标签.然后我尝试了

but there is no tag starting with this hash. Then I've tried

curl https://registry.hub.docker.com///v1/repositories/registry/images

$(...){校验和":","id":"fc251f2434a12eaf8370dee1bc56ab1857978cb769d64e29fea373db699823c6"},{校验和":(..)

$(...){"checksum": "", "id": "fc251f2434a12eaf8370dee1bc56ab1857978cb769d64e29fea373db699823c6"}, {"checksum":(..)

找到了我要寻找的图像.

which found the image I'm looking for.

根据此信息,我可以找到最近的标签吗?

Based on this information may I find the closest tag?

推荐答案

通常,如果自创建标签以来对其进行了修改或删除,通常就无法找出哪些标签在引用给定的图像ID.

Generally it is impossible to find out what tags were referring to a given image ID in the past if the tags were modified or removed since their creation.

如果图像托管在 docker.io/library/* 上(在Docker Hub上也称为官方图像"),则可以浏览此

In case of the images hosted on docker.io/library/* (also known as "official images" on Docker Hub) you can go through the history of this Git repository. Every push of an official image generates a commit to that repo, so it is possible to find out what tags pointed to a particular image ID by making a local clone and using git-grep. The repo is quite huge, so consider using the --depth option of git-clone.

我个人从来没有克隆回购协议.就我而言,我正在寻找官方 postgres 图片的丢失标签,因此我只是通过了

I, personally, never cloned the repo. In my case, I was looking for a missing tag of the official postgres image, so I simply went through the history of postgres's tag-details.md on GitHub's web UI until I found the commits made on the same day when the image was created. Then I carefully clicked through each of them and finally found one particular commit that contained a matching image ID.

P.S.要找出映像的创建日期,请使用 docker image ls my_image_id (相对日期),然后使用 docker image ls my_image_id -f'{{.Created}}'(绝对日期(以UTC为单位).

P.S. To find out the creation date of an image, use docker image ls my_image_id (relative date) and docker image inspect my_image_id -f '{{ .Created }}' (absolute date in UTC).

这篇关于如何基于image_id查找(最近的)标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆