docker / lxc桥接networking

我有这个服务器(主机)有1000个外部IP地址。 我创build了一个运行squid3的docker容器,我需要使用这些ip地址。 我可以从主机启用转发,但只是将请求转发到本地docker ip,因为squid看到的是内部ip,而不是外部ip。

我的问题如下,我怎么玩docker或lxc(docker有lxc指令通过-lxc-conf =),以便我可以在我的容器(例如运行ifconfig)中看到我的主机的外部IP地址。 现在docker开始与它自己的孤立的networking,所以它是无法使用的。

主机的外部IP地址被分配给接口p1p1。

我试着用-lxc-conf =“lxc.network.type = phys”-lxc-conf =“lxc.network.link = p1p1”来运行它,但是这完全破坏了我的主机界面,甚至把我踢出了ssh。

任何想法我做错了什么?

pipe道可以帮助你。

Connect a container to a local physical interface Let's pretend that you want to run two Hipache instances, listening on real interfaces eth2 and eth3, using specific (public) IP addresses. Easy! pipework eth2 $(docker run -d hipache /usr/sbin/hipache) 50.19.169.157 pipework eth3 $(docker run -d hipache /usr/sbin/hipache) 107.22.140.5 Note that this will use macvlan subinterfaces, so you can actually put multiple containers on the same physical interface. 

我认为这是你所需要的。