How to get a list of images on docker registry v2

前端 未结 16 1758
孤城傲影
孤城傲影 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:11

    We wrote a CLI tool for this purpose: docker-ls It allows you to browse a docker registry and supports authentication via token or basic auth.

    0 讨论(0)
  • 2020-12-02 04:11

    Since each registry runs as a container the container ID has an associated log file ID-json.log this log file contains the vars.name=[image] and vars.reference=[tag]. A script can be used to extrapolate and print these. This is perhaps one method to list images pushed to registry V2-2.0.1.

    0 讨论(0)
  • 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: </v2/_catalog?last=pro-octopus-ws&n=100>; 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"]}

    0 讨论(0)
  • 2020-12-02 04:15

    Docker search registry v2 functionality is currently not supported at the time of this writing. See discussion since Feb 2015: "propose registry search functionality #206" https://github.com/docker/distribution/issues/206

    I wrote a script, view-private-registry, that you can find: https://github.com/BradleyA/Search-docker-registry-v2-script.1.0 It is not pretty but it gets the information needed from the private registry.

    Example of output from view-private-registry:

    $ view-private-registry`
    busybox:latest
    gcr.io/google_containers/etcd:2.0.9
    gcr.io/google_containers/hyperkube:v0.21.2
    gcr.io/google_containers/pause:0.8.0
    google/cadvisor:latest
    jenkins:latest
    logstash:latest
    mongo:latest
    nginx:latest
    python:2.7
    redis:latest
    registry:2.1.1
    stackengine/controller:latest
    tomcat:7
    tomcat:latest
    ubuntu:14.04.2
    Number of images:   16
    Disk space used:    1.7G    /mnt/three/docker-registry/registry-data
    
    0 讨论(0)
  • 2020-12-02 04:19

    If some on get this far.

    Taking what others have already said above. Here is a one-liner that puts the answer into a text file formatted, json.

    curl "http://mydocker.registry.domain/v2/_catalog?n=2000" | jq . - > /tmp/registry.lst
    

    This looks like

    {
      "repositories": [
        "somerepo/somecontiner",
        "somerepo_other/someothercontiner",
     ...
      ]
    }
    

    You might need to change the `?n=xxxx' to match how many containers you have.

    Next is a way to automatically remove old and unused containers.

    0 讨论(0)
  • 2020-12-02 04:20

    For the latest (as of 2015-07-31) version of Registry V2, you can get this image from DockerHub:

    docker pull distribution/registry:master
    

    List all repositories (effectively images):

    curl -X GET https://myregistry:5000/v2/_catalog
    > {"repositories":["redis","ubuntu"]}
    

    List all tags for a repository:

    curl -X GET https://myregistry:5000/v2/ubuntu/tags/list
    > {"name":"ubuntu","tags":["14.04"]}
    
    0 讨论(0)
提交回复
热议问题