是否可以为Docker容器分配静态公共IP? [英] Is it possible to assign a static public ip to a Docker Container?

查看:449
本文介绍了是否可以为Docker容器分配静态公共IP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将我的五个公共ip中的一个分配给我的docker容器。似乎这是可能的,因为码头的性质及其用途。我发现这个网站,我认为解释了我想做什么,但是从Docker离开LXC起就不再工作了。



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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆