How to get a list of images on docker registry v2

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

    This has been driving me crazy, but I finally put all the pieces together. As of 1/25/2015, I've confirmed that it is possible to list the images in the docker V2 registry ( exactly as @jonatan mentioned, above. )

    I would up-vote that answer, if I had the rep for it.

    Instead, I'll expand on the answer. Since registry V2 is made with security in mind, I think it's appropriate to include how to set it up with a self signed cert, and run the container with that cert in order that an https call can be made to it with that cert:

    This is the script I actually use to start the registry:

    sudo docker stop registry
    sudo docker rm -v registry
    sudo docker run -d \
      -p 5001:5001 \
      -p 5000:5000 \
      --restart=always \
      --name registry \
      -v /data/registry:/var/lib/registry \
      -v /root/certs:/certs \
      -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
      -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \ 
      -e REGISTRY_HTTP_DEBUG_ADDR=':5001' \
      registry:2.2.1
    

    This may be obvious to some, but I always get mixed up with keys and certs. The file that needs to be referenced to make the call @jonaton mentions above**, is the domain.crt listed above. ( Since I put domain.crt in /root, I made a copy into the user directory where it could be accessed. )

    curl --cacert ~/domain.crt https://myregistry:5000/v2/_catalog
    > {"repositories":["redis","ubuntu"]}
    

    **The command above has been changed: -X GET didn't actually work when I tried it.

    Note: https://myregistry:5000 ( as above ) must match the domain given to the cert generated.

提交回复
热议问题