Docker: Refer to registry by ip address

回眸只為那壹抹淺笑 提交于 2019-12-05 01:52:05

问题


I have a Docker image I want to push to my registry (hosted on localhost). I do:

docker push localhost:5000/my_image

and works properly. However, if I tag the image and push it by:

docker push 172.20.20.20:5000/my_image

I get an error.

The push refers to a repository [172.20.20.20:5000/my_tomcat] (len: 1)
unable to ping registry endpoint https://172.20.20.20:5000/v0/ v2
ping attempt failed with error:
Get https://172.20.20.20:5000/v2/: Gateway Time-out

Can't I refer to registry by IP? If so, how could I push an image from another host that it is not localhost?

EDIT

I'm running the registry this way:

docker run -d -p 5000:5000 --restart=always --name registry registry:2

回答1:


As mentioned in "IPs for all the Things" (by Jess Frazelle), you should be able, with docker 1.10, to run your registry with a fixed IP address.

It uses the --net= --ip= options of docker run.

# create a new bridge network with your subnet and gateway for your ip block
$ docker network create --subnet 203.0.113.0/24 --gateway 203.0.113.254 iptastic

# run a nginx container with a specific ip in that block
$ docker run --rm -it --net iptastic --ip 203.0.113.2 nginx

# curl the ip from any other place (assuming this is a public ip block duh)
$ curl 203.0.113.2

You can adapt this example to your registry docker run parameters.




回答2:


First of all please check whether you are able to connect the registry on the port 5000. In Linux/windows you can do this using telnet. below is the command.

$ telnet 172.20.20.20 5000

If the connectivity check is failed then please check your firewall settings.

I am not sure whether you are running your running registry with login functionality. But from the question i can assume that you are not using it. In this case please add your registry as an insecure registry in the docker daemon from which you are trying to access the registry. The process is described here - https://docs.docker.com/registry/insecure/

Please let me know if are successful.



来源:https://stackoverflow.com/questions/35314092/docker-refer-to-registry-by-ip-address

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!