How to get a list of images on docker registry v2

前端 未结 16 1808
孤城傲影
孤城傲影 2020-12-02 04:04

I\'m using docker registry v1 and I\'m interested in migrating to the newer version, v2. But I need some way to get a list of images present on registry; for example with re

16条回答
  •  情书的邮戳
    2020-12-02 04:13

    Get catalogs

    Default, registry api return 100 entries of catalog, there is the code:

    When you curl the registry api:

    curl --cacert domain.crt https://your.registry:5000/v2/_catalog

    it equivalents with:

    curl --cacert domain.crt https://your.registry:5000/v2/_catalog?n=100

    This is a pagination methond.

    When the sum of entries beyond 100, you can do in two ways:

    First: give a bigger number

    curl --cacert domain.crt https://your.registry:5000/v2/_catalog?n=2000

    Sencond: parse the next linker url

    curl --cacert domain.crt https://your.registry:5000/v2/_catalog

    A link element contained in response header:

    curl --cacert domain.crt https://your.registry:5000/v2/_catalog

    response header:

    Link: ; rel="next"

    The link element have the last entry of this request, then you can request the next 'page':

    curl --cacert domain.crt https://your.registry:5000/v2/_catalog?last=pro-octopus-ws

    If the response header contains link element, you can do it in a loop.

    Get Images

    When you get the result of catalog, it like follows:

    { "repositories": [ "busybox", "ceph/mds" ] }

    you can get the images in every catalog:

    curl --cacert domain.crt https://your.registry:5000/v2/busybox/tags/list

    returns:

    {"name":"busybox","tags":["latest"]}

提交回复
热议问题