Method of Docker Query or Obtain Mirror in Private Warehouse

Time:2019-10-9

Doker queries or retrieves mirrors in a private repository, using


docker search 192.168.1.8:5000

Commands are not well tested.

Solve:

1. Get the mirror image of the warehouse class:


[[email protected] docker]# curl -XGEThttp://192.168.1.8:5000/v2/_catalog

{"repositories":["nginx"]}

2. Get a list of labels for a mirror:


[[email protected] 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"}}]}

[[email protected] docker]# curl -XGEThttp://192.168.1.8:5000/v2/nginx/tags/list

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

[[email protected] docker]#

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

PS: View all the labels of the mirrors in the Docker Mirror Warehouse


#!/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 query through the restful API of the mirror warehouse, then simply process the returned JSON results, and print them out.

The implementation of the above script is to query only from hub. docker. com. If you use other warehouses, you can modify the URL of the warehouse as needed.

The above is the whole content of this article. I hope it will be helpful to everyone’s study, and I hope you will support developpaer more.

Recommended Today

Laravel returns the unified format error code

background Recently, I was learning to develop an Android project. The back-end interface project started a new project with PHP’s yii2.0 framework, and then changed to laravel 5.5. Recently, I saw that laravel upgraded the new version, so I updated the project to laravel 6.4In the process of using Yii and laravel, both frameworks are […]