Docker:通过ip地址参考注册表 [英] Docker: Refer to registry by ip address
问题描述
我有一个Docker镜像,我想推送到我的注册表(托管在 localhost
)。我做:
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
我收到错误。
推送是指存储库[172.20.20.20:5000/my_tomcat](len:1) code>
无法ping注册表端点https://172.20.20.20:5000/v0/ v2
ping尝试失败并出现错误:
获取https://172.20.20.20:5000/v2/:网关超时
我不能通过IP引用注册表?如果是这样的话,我该怎么把另一个主机的图像推送出去? localhost
?
Can't I refer to registry by IP? If so, how could I push an image from another host that it is not localhost
?
编辑
我以这种方式运行注册表:
I'm running the registry this way:
docker run -d -p 5000:5000 --restart=always --name registry registry:2
推荐答案
如所有事情的知识产权(通过 Jess Frazelle ),您应该能够使用docker 1.10,以固定的IP地址运行注册表。
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
您可以将此示例调整为注册表Docker运行参数。
You can adapt this example to your registry docker run parameters.
这篇关于Docker:通过ip地址参考注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!