Docker:通过 IP 地址引用注册表



我有一个 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:
Get https://172.20.20.20:5000/v2/: Gateway Time-out

我不能按 IP 引用注册表吗?如果是这样,我怎么能从另一台主机推送它不是localhost的映像?

编辑

我以这种方式运行注册表:

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

正如Jess Frazelle在"IP for all the Things"(Jess Frazelle)中提到的,使用docker 1.10,您应该能够使用固定的IP地址运行注册表。

它使用 docker 运行的--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

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

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

$ telnet 172.20.20.20 5000

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

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

如果成功,请告诉我。

最新更新