Docker:通过IP地址引用registry

我有一个我想推到我的registry(托pipe在localhost )的Docker镜像。 我做:

 docker push localhost:5000/my_image 

并正常工作。 但是,如果我标记图像,并推送它:

 docker push 172.20.20.20:5000/my_image 

我得到一个错误。

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

我不能通过IP来引用registry吗? 如果是这样,我怎么能从另一个主机,它不是localhost主机推图像?

编辑

我以这种方式运行registry:

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

正如在“ 所有事情的知识产权 ”(由Jess Frazelle所述 )中所提到的那样,您应该能够使用docker 1.10来运行您的registry,并使用固定的IP地址。

它使用--net= --ip=选项 。

 # 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 

您可以将此示例应用于您的registrydocker运行参数。

首先请检查您是否能够连接端口5000上的registry。在Linux / Windows中,您可以使用telnet执行此操作。 下面是命令。

$ telnet 172.20.20.20 5000

如果连接检查失败,请检查您的防火墙设置。

我不确定您是否正在运行您的运行registry与loginfunction。 但是从这个问题我可以假设你没有使用它。 在这种情况下,请将您的registry添加为您尝试访问registry的docker守护进程中不安全的registry。 这个过程在这里描述 – https://docs.docker.com/registry/insecure/

请让我知道如果成功。