Docker:通过ip地址参考registry

Docker: Refer to registry by ip address

我有一个 Docker 图像,我想将其推送到我的注册表(托管在 localhost 上)。我愿意:

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:<br> Get https://172.20.20.20:5000/v2/: Gateway Time-out

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

编辑

我是这样 运行 注册表的:

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

如“IPs for all the Things" (by Jess Frazelle) 中所述,使用 docker 1.10,您应该能够使用固定 IP 地址 运行 您的注册表。

它使用 --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

您可以将此示例调整为您的注册表 docker 运行 参数。

首先请检查您是否能够在端口 5000 上连接注册表。在 Linux/windows 中,您可以使用 telnet 来完成此操作。下面是命令。

$ 远程登录 172.20.20.20 5000

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

我不确定您是否 运行 您的 运行 注册表具有登录功能。但是从这个问题我可以假设你没有使用它。在这种情况下,请将您的注册表作为不安全的注册表添加到您尝试访问注册表的 docker 守护程序中。该过程在此处描述 - https://docs.docker.com/registry/insecure/

如果成功请告诉我。