docker A way to query or get an image in the private repository of registry

  • 2021-01-22 08:20:24
  • OfStack

docker queries or gets an image in a private repository (registry), using


docker search 192.168.1.8:5000

The command did not test well.

Solution:

Get the repository class mirroring:


[root@shanghai docker]# curl -XGEThttp://192.168.1.8:5000/v2/_catalog

{"repositories":["nginx"]}

Get a list of tags from an image:


[root@shanghai docker]# curl -XGEThttp://192.168.1.8:5000/v2/image_name/tags/list

{"errors":[{"code":"NAME_UNKNOWN","message":"repositoryname not known toregistry","detail":{"name":"image_name"}}]}

[root@shanghai docker]# curl -XGEThttp://192.168.1.8:5000/v2/nginx/tags/list

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

[root@shanghai docker]#

Reference: https: / / stackoverflow com/questions / 23733678 / how - to - search images - from private - 1-0 - registry in -- docker

PS: View all labels for images in the Docker mirror repository


#!/bin/sh

repo_url=https://registry.hub.docker.com/v1/repositories
image_name=$1

curl -s ${repo_url}/${image_name}/tags | json_reformat | grep name | awk '{print $2}' | sed -e 's/"//g'

In fact, the implementation method is to mirror the warehouse restful API, to query, and then return json results simple processing 1, and then print out.

The implementation of the above script is to query from hub.docker.com only. If you are using another repository, you can modify the repository's url as needed.


Related articles: