88

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 ? :)

gavioto
  • 1,695
  • 2
  • 17
  • 38
edwardsbean
  • 3,619
  • 5
  • 21
  • 25

10 Answers10

93

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

iTech
  • 18,192
  • 4
  • 57
  • 80
88

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"]}
snth
  • 5,194
  • 4
  • 39
  • 48
74

As of v 0.7.0 of the private registry you can do:

$ curl -X GET http://localhost:5000/v1/search?q=postgresql

and you will get a json payload:

{"num_results": 1, "query": "postgresql", "results": [{"description": "", "name": "library/postgresql"}]}

to give more background here is how I started my registry:

docker run \
        -e SETTINGS_FLAVOR=local \
        -e STORAGE_PATH=/registry \
        -e SEARCH_BACKEND=sqlalchemy \
        -e LOGLEVEL=DEBUG \
        -p 5000:5000 \
        registry
Larry Cai
  • 55,923
  • 34
  • 110
  • 156
faide
  • 766
  • 5
  • 3
  • so this is undocumented feature for `search` – Larry Cai Aug 07 '14 at 02:08
  • 6
    see reference for this issue https://github.com/docker/docker-registry/issues/63 `curl -X GET http://localhost:5000/v1/search` can list all images – Larry Cai Aug 07 '14 at 02:17
  • 13
    As of api v2 it is done with `http://localhost:5000/v2/_catalog` https://docs.docker.com/registry/spec/api/ – mimo Jan 28 '16 at 05:55
19

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

mre
  • 1,813
  • 4
  • 28
  • 37
15

List all images

docker search <registry_host>:<registry_port>/

List images like 'vcs'

docker search <registry_host>:<registry_port>/vcs
smishra
  • 3,122
  • 29
  • 31
13

Was able to get everything in my private registry back by searching just for 'library':

docker search [my.registry.host]:[port]/library

Returns (e.g.):

NAME                    DESCRIPTION   STARS     OFFICIAL   AUTOMATED
library/custom-image                  0                    
library/another-image                 0                    
library/hello-world                   0
  • 41
    With docker 1.8.1 on Ubuntu 14.04 I'm getting `Error response from daemon: Unexpected status code 404`, what's wrong? – carloreggiani Aug 26 '15 at 15:09
  • 4
    I have the same problem the command 'docker search repositroy_ip:5000/busybox' returns the 404, but previous command 'docker push repository_ip:5000/busybox' has succeeded – ksopyla Sep 29 '15 at 07:31
  • 1
    you may need to use curl for insecure registries, e.g. `curl --insecure -u "test:password" https://myregistrydomain.com:5000/v2/_catalog` – Leon Mak May 29 '19 at 10:27
  • "If you start your docker-registry without enabling search, then this UI won't work and it's not obvious why. I was able to add the registry just fine because http://docker-registry-host:5000/v1/ping returns HTTP 200, but when navigating to the Images the UI will report the "Registry is Unreachable" b/c http://docker-registry-host:5000/v1/search returns HTTP 404." https://github.com/atcol/docker-registry-ui/issues/65#issuecomment-68060219 – sm4rk0 Feb 03 '20 at 12:40
5

I installed the atc-/docker-registry-web project that gives me UI and search for my private registry. https://github.com/atc-/docker-registry-web

It is dockerised and you can just run it by

docker run -p 8080:8080 -e REG1=http://registry_host.name:5000/v1/ atcol/docker-registry-ui

and review contents by browsing to registry_ui_host.name:8080

Adaephon
  • 16,929
  • 1
  • 54
  • 71
Larisa Sabban
  • 59
  • 1
  • 1
2

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/.

odk
  • 2,144
  • 1
  • 16
  • 10
  • sorry,i mean how to search images from private registry by command line or http – edwardsbean May 20 '14 at 04:11
  • Yes I know but AFAIK without index you can't search images in private registry. There is `/v1/search` api method in registry but it requires index backend. There is basic index implementation in private registry code ( https://github.com/dotcloud/docker-registry/blob/master/docker_registry/index.py ) but it's only to provide basic functions in standalone mode. Few days ago I found this: https://github.com/ekristen/docker-index but didn't have time to test is. – odk May 20 '14 at 07:56
1

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

docker exec -it <your_registry_container_id> ls -a /var/lib/registry/docker/registry/v2/repositories/
Dale K
  • 25,246
  • 15
  • 42
  • 71
user9269906
  • 111
  • 1
  • 6
  • Also for listing tags of a repository: docker exec -it ls -a /var/lib/registry/docker/registry/v2/repositories/postgresql/_manifests/tags – Mohsen Abasi Jul 22 '20 at 07:12
0

Another method in one line (substitute your actual path/ports if needed).

Example: Assume a generic registry:2.0 start up, the running registry container has a log file that holds images 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.

Corey
  • 1,217
  • 3
  • 22
  • 39