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

Héc*_*tor 5 docker docker-registry

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

docker push localhost:5000/my_image
Run Code Online (Sandbox Code Playgroud)

并且工作正常。但是,如果我标记图像并通过以下方式推送它:

docker push 172.20.20.20:5000/my_image
Run Code Online (Sandbox Code Playgroud)

我收到一个错误。

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

编辑

我这样运行注册表:

docker run -d -p 5000:5000 --restart=always --name registry registry:2
Run Code Online (Sandbox Code Playgroud)

Von*_*onC 4

正如“所有事物的 IP ”(作者Jess Frazelle)中提到的,您应该能够使用 docker 1.10 使用固定 IP 地址运行注册表。

它使用--net= --ip=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
Run Code Online (Sandbox Code Playgroud)

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