使用IP地址而不是localhost或127.0.0.1的本地Docker Registry

时间:2020-08-05 06:22:41

标签: docker

通过点击链接local-docker-registry,我可以创建本地Docker注册表。而且,如果我尝试从注册表中使用docker pull,那么它正在与localhost配合使用。但是,如果我使用docker pull尝试使用IP地址(192.168.1.100),则会卡住。有什么方法可以使用来自其他节点的本地docker登录。就像我在Node_1和Node_2中启动docker注册表一样,Node_3可以使用相同的注册表通过ip adrres的repo URL下载图像。

sudo docker ps | grep 5000 

ac85ef5e1468 registry:2  "/entrypoint.sh /etc…"   0.0.0.0:5000->5000/tcp   registry

Docker与本地主机的拉取结果

$docker pull localhost:5000/<repo path>/<my image name>

2020.3.0-05-e00b8b5: Pulling from <repo path>/<my image name> 
6cf436f81810: Already exists 
...
7a4174f2f781: Already exists
12625989883c: Pull complete 
704db5aa2eb9: Pull complete 
Extracting [===>                 688.1kB/8.76MB 
de0615bc3c45: Download complete
fbaceba9fc67: Download complete

使用IP地址无法正常工作:

$docker pull 192.168.1.100:5000/<repo path>/<my image name>`

Error response from daemon: Get https://192.168.1.100:5000/v2/: 
net/http: request canceled while waiting for connection
(Client.Timeout exceeded while awaiting headers)

提前感谢您的任何建议。

1 个答案:

答案 0 :(得分:0)

在其他节点上运行

 sudo service docker stop
 vi /etc/docker/daemon.json 
{
"insecure-registries" : [ "192.168.1.100:5000" ]
}
//add the entry 
vi /etc/sysconfig/docker
ADD_REGISTRY='--add-registry 192.168.1.100:5000'
// Add this
start the docker service: service start docker
Check the command
docker info
Registry: https://192.168.1.100:5000/v1/
Experimental: false
Insecure Registries:
 192.168.1.100:5000
 127.0.0.0/8

This has to perform from all the nodes where you want to make the default registry as private registry.
now run : docker pull <image name>
//it should pull from private registry
相关问题