SoFunction
Updated on 2025-03-10

Docker method to query or obtain a mirror in a private repository (registry)

docker query or obtain a mirror in a private repository, using

docker search 192.168.1.8:5000

The command was not working well after testing.

solve:

1. Get the image of the warehouse class:

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

{"repositories":["nginx"]}

2. Get the tag list of a certain 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]#

refer to:/questions/23733678/how-to-search-images-from-private-1-0-registry-in-docker

PS: View all tags of images in Docker image repository

#!/bin/sh

repo_url=/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 repository, then simply process the returned json result, and then print it out.

The implementation of the above script is to query only. If you use other repositories, you can modify the url of the repository as needed.

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.