docker私有仓库(registry V1和registry V2)操作

仓库v1和v2版本的镜像包:

链接:https://pan.baidu.com/s/1T4snL6ntNqCtxkF4eiUPcA 
提取码:jpfe 

 

registry V1版本私有仓库操作

1、查看registry V1仓库是否可用
curl "http://192.168.23.100:5001"

2、查看registry V1仓库的所有镜像
curl "http://192.168.23.100:5001/v1/search" 


[root@k8smaster zhaiky]# docker -H 192.168.23.100:2375 run  -d -e SETTINGS_FLAVOR=dev -e STORAGE_PATH=/tmp/registry -v /data/registry1:/tmp/registry -p 192.168.23.100:5001:5000  --restart=always 192.168.23.100:5000/registry:v1  #运行V1版本私有仓库
758f01023a9551c16f1c7c7af0ca47d9f3ec9ca70658d55ca4f5afb93c47d239
[root@k8smaster zhaiky]# curl "http://192.168.23.100:5001" #查看V1版本仓库是否服务正常
"\"docker-registry server\""
[root@k8smaster zhaiky]#
[root@k8smaster zhaiky]# curl "http://192.168.23.100:5001/v1/search"  #列出V1版本仓库中的所有镜像
{"num_results": 0, "query": "", "results": []}
[root@k8smaster zhaiky]#

registry V2版本私有仓库操作

1、查看registry V2仓库是否可用
[root@k8smaster zhaiky]# docker run -d -p 5000:5000 --restart=always --name private-docker-registry12 --privileged=true -e REGISTRY_STORAGE_DELETE_ENABLED="true" -v /data/registry:/var/lib/registry 192.168.23.100:5000/registry:v2   #运行V2版本私有仓库
6aae830ba4562706ef5d04696e10b6153b2e015ac80abc0d052ff015ad8211af
[root@k8smaster zhaiky]# curl "http://192.168.23.100:5000/v2"  #查看V2版本仓库是否服务正常
<a href="/v2/">Moved Permanently</a>.

2、列出私有仓库registry V2的镜像列表
# curl -X GET http://<registry_ip>:<registry_port>/v2/_catalog
[root@k8smaster ~]# curl -X GET http://192.168.23.100:5000/v2/_catalog #列出V2版本仓库中的所有镜像
{"repositories":["busybox","centos","coredns","coreos/flannel","etcd","kube-apiserver","kube-controller-manager","kube-proxy","kube-scheduler","kubernetes-ingress-controller/nginx-ingress-controller","nginx","pause","registry","tomcat"]}
[root@k8smaster ~]#

3、列出指定镜像的所有标签
# curl -X GET http://<registry_ip>:<registry_port>/v2/<image_name>/tags/listt
[root@k8smaster ~]# curl -X GET htp://192.168.23.100:5000/v2/tomcat/tags/list #列出指定镜像的所有标签
{"name":"tomcat","tags":["v2"]}
[root@k8smaster ~]# 

4、获取镜像信息
[root@k8smaster ~]# curl -v --silent -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -X GET  http://192.168.23.100:5000/v2/tomcat/manifests/v2 #查询具体镜像信息
* About to connect() to 192.168.23.100 port 5000 (#0)
*   Trying 192.168.23.100...
* Connected to 192.168.23.100 (192.168.23.100) port 5000 (#0)
> GET /v2/tomcat/manifests/v2 HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 192.168.23.100:5000
> Accept: application/vnd.docker.distribution.manifest.v2+json

< HTTP/1.1 200 OK
< Content-Length: 2833
< Content-Type: application/vnd.docker.distribution.manifest.v2+json
< Docker-Content-Digest: sha256:635138228afd424e8c45ebef8127a63c3ea4b99da3cc63ba4230f40f8b6d287d
< Docker-Distribution-Api-Version: registry/2.0
< Etag: "sha256:635138228afd424e8c45ebef8127a63c3ea4b99da3cc63ba4230f40f8b6d287d"
< X-Content-Type-Options: nosniff
< Date: Mon, 17 Feb 2020 22:54:48 GMT

5、删除镜像
[root@k8smaster ~]# curl -v --silent -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -X DELETE http://192.168.23.100:5000/v2/tomcat/manifests/sha256:635138228afd424e8c45ebef8127a63c3ea4b99da3cc63ba4230f40f8b6d287d  #删除私有仓库里面的镜像
* About to connect() to 192.168.23.100 port 5000 (#0)
*   Trying 192.168.23.100...
* Connected to 192.168.23.100 (192.168.23.100) port 5000 (#0)
> DELETE /v2/tomcat/manifests/sha256:635138228afd424e8c45ebef8127a63c3ea4b99da3cc63ba4230f40f8b6d287d HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 192.168.23.100:5000
> Accept: application/vnd.docker.distribution.manifest.v2+json

< HTTP/1.1 202 Accepted
< Docker-Distribution-Api-Version: registry/2.0
< X-Content-Type-Options: nosniff
< Date: Mon, 17 Feb 2020 22:56:46 GMT
< Content-Length: 0

* Connection #0 to host 192.168.23.100 left intact
[root@k8smaster ~]# 

发布了60 篇原创文章 · 获赞 20 · 访问量 4608

猜你喜欢

转载自blog.csdn.net/zhaikaiyun/article/details/104400746