Docker系列三:DockerHub私有仓库的搭建

server1=192.168.1.40
server2=192.168.205.10
自己在server1机器上搭建
systemctl start docker
docker run -d -p 5000:5000 --restart always --name registry registry:2
server2测试server1能不能通:
telnet 192.168.1.40 5000

开始构建:
docker build -t 192.168.1.40:5000/hello-word .
#文件名写服务器的ip:5000/hello-word .

docker push 192.168.1.40:5000/hello-word
The push refers to repository [192.168.1.40:5000/hello-word]
Get https://192.168.1.40:5000/v2/: http: server gave HTTP response to HTTPS client
这时候就需要添加一下认证。
vim /etc/docker/daemon.json
添加
{ "insecure-registries":["192.168.1.40:5000"] }

[root@docker-host vim]# systemctl restart docker
[root@docker-host vim]# docker push 192.168.1.40:5000/hello-word
The push refers to repository [192.168.1.40:5000/hello-word]

docker registry api 可以验证是否可以成功

在浏览器上打开server端的地址:
http://192.168.1.40:5000/v2/_catalog
浏览器显示:
{"repositories":["hello-word"]}
说明上传成功!

本地测试:
docker image rm [ID]

[root@docker-host vim]# docker pull 192.168.1.40:5000/hello-word
Using default tag: latest
latest: Pulling from hello-word
256b176beaff: Already exists 
67582eb30561: Pull complete 
Digest: sha256:f1c31b6c44cba701b59ad71b0f39a6c2ba1aa9cf5b6f3e75e26ac93d6590bba2
Status: Downloaded newer image for 192.168.1.40:5000/hello-word:latest

docker image ls
说明上传成功和下载也成功

猜你喜欢

转载自blog.csdn.net/weixin_36171533/article/details/81610749