![8123c5102a4bc4789bbc0b6e3d0e8c66.png](https://img-blog.csdnimg.cn/img_convert/8123c5102a4bc4789bbc0b6e3d0e8c66.png)
1、下载Registry镜像
docker pull registry:lastest
2、启动镜像仓库
docker run --name registry -p 5000:5000 --restart=always -v /usr/local/registry:/var/lib/registry -d registry
3、查看镜像仓库的镜像
curl http://镜像仓库IP地址:5000/v2/_catalog
当第一次启动还没有上传镜像到镜像仓库时返回的是空的json
{"repositories":[]}
4、标记镜像
docker tag eladmin-system 镜像仓库地址/eladmin-system:test
5、上传镜像仓库
docker push 镜像仓库IP地址:5000/eladmin-system:test
上传结果
[root@VM-0-12-centos ~]# docker push 127.0.0.1:5000/eladmin-system:test
The push refers to a repository [镜像仓库IP地址/eladmin-system]
125282fb2669: Pushed
a70736c90206: Pushed
35c20f26d188: Pushed
c3fe59dd9556: Pushed
6ed1a81ba5b6: Pushed
a3483ce177ce: Pushed
ce6c8756685b: Pushed
30339f20ced0: Pushed
0eb22bfb707d: Pushed
a2ae92ffcd29: Pushed
test: digest: sha256:9656f00c3baf2231d4e065f21e733cb637c78d297e47d1361a93c1449ef21eb1 size: 2424
6、查看上传镜像
curl 镜像仓库IP地址/v2/_catalog
上传结果:
{"repositories":["eladmin-system"]}
7、下载上传的镜像
docker pull http://镜像仓库IP地址:5000/eladmin-system:test
如果私有仓库没有配置https,下载镜像时会出现如下错误:
Error response from daemon: Get https://镜像仓库IP地址:5000/v1/_ping: http: server gave HTTP response to HTTPS client
遇到以上问题,进行如下操作
- 创建dameno.json文件并写入如下内容
echo '{ "insecure-registries":["镜像仓库IP地址:5000"] }' > /etc/docker/daemon.json
注意:如果该文件存在,直接修改该文件内容即可
{
"insecure-registries" : [ "your-server-ip:5000" ]
}
- 重启docker
systemctl restart docker
- 重新下载
docker pull 镜像仓库IP地址:5000/eladmin-system:test
下载成功结果
test: Pulling from eladmin-system
Digest: sha256:9656f00c3baf2231d4e065f21e733cb637c78d297e47d1361a93c1449ef21eb1
Status: Downloaded newer image for 镜像仓库地址:5000/eladmin-system:test