【问题标题】:API for redhat base image to get values of image tags?用于redhat基础图像的API来获取图像标签的值?
【发布时间】:2020-04-13 14:23:03
【问题描述】:

我们是否有 API 以编程方式获取下图的图像标签值?

https://access.redhat.com/containers/?tab=tags&get-method=registry-tokens#/registry.access.redhat.com/rhel7

用例: 如果有新的标签版本可用,请获取更高版本。

我正在寻找类似以下的内容:

wget -q https://registry.hub.docker.com/v1/repositories/debian/tags -O -  | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n'  | awk -F: '{print $3}'

以上解决方案来自stackoverflow问题:

https://stackoverflow.com/questions/28320134/how-can-i-list-all-tags-for-a-docker-image-on-a-remote-registry

我做到了

wget https://access.redhat.com/containers/?tab=tags&get-method=registry-tokens#/registry.access.redhat.com/rhel7

不幸的是,它提供了很多无用的冗余数据。

我很感激任何线索。

谢谢

【问题讨论】:

    标签: docker redhat-containers


    【解决方案1】:

    一种选择是使用skopeo 命令获取有关远程映像的信息。例如,如果您运行:

    skopeo inspect docker://registry.access.redhat.com/rhel7
    

    您将获得一大块 JSON 数据,其中包含有关所有可用标签的信息:

    {
        "Name": "registry.access.redhat.com/rhel7",
        "Digest": "sha256:11ec91dcb3505f6eaa02d815fab39078786f3ddbef26796e3ef348410ca43b9d",
        "RepoTags": [
            "7.3-74",
            "7.4-120",
            "7.2-56",
            "7.3-89",
            "7.3-66",
            "7.5-424",
            "7.5-245.1527091554",
            "7.4-129",
            "7.1-12",
            "7.6-122",
            "7.3-82",
            "7.7-384.1575996163",
            "7.5-409.1533127727",
            "7.2-75",
            "7.2-38",
            "7.6",
    [...]
    

    (总共大约有 70 个。)

    由于skopeo 返回 JSON 结果,因此很容易获取此输出并以编程方式对其进行解析以提取您想要的信息。


    使用来自skopeo (skopeo --debug ...) 的调试输出,我看到标签列表也可以从https://registry.access.redhat.com/v2/rhel7/tags/list 获得。这似乎无需身份验证即可工作,所以也许这是最简单的选择。

    【讨论】:

    • 先生,是的,我知道 skopeo,但苦涩的现实是我没有运气将它安装在 EC2(Amazon Linux 2)上。我正在使用 EC2 t2.medium
    • 然后使用我在答案第二部分中提到的HTTP API。
    • 画面完美!是的,你给的网址就像一个魅力!谢谢,堆:)
    猜你喜欢
    • 2017-12-30
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-09
    • 2020-02-17
    相关资源
    最近更新 更多