是否可以为Docker容器分配静态公共IP? [英] Is it possible to assign a static public ip to a Docker Container?
问题描述
http://programster.blogspot.com/2014/06/docker-run-multiple-docker -websites-on.html
我尝试使用我的容器正在使用的ip进行静态NAT连接,但没有起作用。 docker IP不显示在我的路由器页面,只有主机ip。
我的问题是:
是否可以为docker容器分配一个静态的public ip,如果是这样呢?
和
是否可以在我的路由器配置页面中出现docker IP,如果是这样?
谢谢。
可能的解决方案,但我现在无法测试。请让我知道这是不正确的。
使用macvlan进行虚拟网络接口:
请参阅 https://superuser.com/questions/175475/ ip-address-alias-assigned-by-dhcp
命令:
ip link add dev macvlan0 link eth0 type macvlan#macvlan0是v-card(lol)的名称
将容器连接到具有管道功能的虚拟网络接口:
请参阅 https://github.com/jpetazzo/pipework/#connect-a-container-to-a-local-physical-interface
命令:
pipework macvlan0 $($ containerid)dhcp
I have been trying to assign one of my five public ip's to my docker container. It seems like this should be possible because of the nature of docker and its uses. I found this website that I think explains what I want to do but it no longer works since Docker went away from LXC:
http://programster.blogspot.com/2014/06/docker-run-multiple-docker-websites-on.html
I have tried making a static NAT connection with the ip that my container was using but that didn't work. The docker IP does not show up in my routers page, only the host computers ip.
My questions are:
Is it possible to assign a static public ip to a docker container, and if so how?
and
Is it possible to make a docker IP appear in my router config page, and if so how?
Thanks.
Possible Solution but I can't test it right now. Please let me know if this is incorrect.
Make virtual network interface with macvlan:
See https://superuser.com/questions/175475/ip-address-alias-assigned-by-dhcp
commands:
ip link add dev macvlan0 link eth0 type macvlan #macvlan0 being the name of the v-card (lol)
Connect container to virtual network interface with pipework:
see https://github.com/jpetazzo/pipework/#connect-a-container-to-a-local-physical-interface
commands:
pipework macvlan0 $($containerid) dhcp
这篇关于是否可以为Docker容器分配静态公共IP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!