How to search images from private 1.0 registry in

2019-01-21 00:44发布

I made a private registry,curl xx.xx.xx.xx:5000 is ok. I push an image into docker private registry by doing: docker push xx.xx.xx.xx:5000/centos
it return:
http://xx.xx.xx.xx:5000/v1/repositories/centos/tags/latest

the question is how to get all images from registry web or command whatever. I cant find any information from docker registry api. any one helps ? :)

10条回答
Fickle 薄情
2楼-- · 2019-01-21 00:58

Currently there's no search support for Docker Registry v2.

There was a long-running thread on the topic. The current plan is to support search with an extension in the end, which should be ready by v2.1.

As a workaround, execute the following on the machine where your registry v2 is running:

> docker exec -it <your_registry_container_id> bash
> ls /var/lib/registry/docker/registry/v2/repositories/

The images are in subdirectories corresponding to their namespace, e.g. jwilder/nginx-proxy

查看更多
SAY GOODBYE
3楼-- · 2019-01-21 01:01

Currently AFAIK there is no easy way to do this as this information should be stored by index which private registry doesn't have. But depending on how you started registry you have 2 options:

  1. if you started registry without -v to store data in separate host folder you can try with docker diff <id_of_registry_container> with this you should get info about changes in container fs. All pushed images should be somewhere in /tmp/registry/repositories/
  2. if you started registry with -v just check content of mounted directory on host

If you used "centos" as name it should be in /tmp/registry/repositories/library/centos. This folder will contain text files which describes image structure. Actual data is in /tmp/registry/images/.

查看更多
干净又极端
4楼-- · 2019-01-21 01:03

Now from docker client you can simply search your private registry directly without using the HTTP APIs or any extra tools:

e.g. searching for centos image:

docker search localhost:5000/centos

查看更多
【Aperson】
5楼-- · 2019-01-21 01:05

Another method one line (substitute your actual path/ports if needed). Example: assumes a generic registry:2.0 start up The running registry container has a log file that holds image and tag names. I extrapolate the data like this:

grep -r -o "vars.name=.* vars.reference=." /var/lib/docker/containers/ | cut -c 167-225 | sed 's/ver.*$//' | sed 's/vars.name=//' | sed 's/ vars.reference=/:/' | sort -u

you may need to tweak the cut values to get the output desired.

查看更多
何必那么认真
6楼-- · 2019-01-21 01:08

So I know this is a rapidly changing field but (as of 2015-09-08) I found the following in the Docker Registry HTTP API V2:

Listing Repositories (link)

GET /v2/_catalog

Listing Image Tags (link)

GET /v2/<name>/tags/list

Based on that the following worked for me on a local registry (registry:2 IMAGE ID 1e847b14150e365a95d76a9cc6b71cd67ca89905e3a0400fa44381ecf00890e1 created on 2015-08-25T07:55:17.072):

$ curl -X GET http://localhost:5000/v2/_catalog
{"repositories":["ubuntu"]}
$ curl -X GET http://localhost:5000/v2/ubuntu/tags/list
{"name":"ubuntu","tags":["latest"]}
查看更多
干净又极端
7楼-- · 2019-01-21 01:08

Modifying answer from @mre to get the listing just from one command (valid at least for Docker Registry v2)

docker exec -it ls -a /var/lib/registry/docker/registry/v2/repositories/

查看更多
登录 后发表回答