具有不同networking接口的Docker容器

问题:我想在Docker容器中运行多个VPN服务器,每个都有自己的公有IP。

使用-p参数,我可以分别连接到每一个,但是我看到的公共IP是eth0接口,而不是我想要的(eth0:1),所以我如何创build一个新的docker0接口eth0:1作为stream量的接口?

最好的问候和感谢。

Docker不使用它之外的networking。 对于来自世界各地的主机与容器之间的连接,使用端口绑定。 在创buildDocker镜像时将端口公开在Dockerfile中将Docker容器公开到主机:公开容器对于主机识别运行哪个端口容器非常重要。 -p在docker run命令中用来暴露端口。 语法:docker run -p host_ip:host_port:container_port image_name例如,docker run -itd -p 192.168.134.122:1234:1500 image_name
这将容器的端口1500绑定到主机的192.168.134.122上的端口1234。
使用iptables来查看networking进程 – iptables -L -n -t nat

Now the request send to host_ip (192.168.134.122) and port (1243) is redirect to container with ip (172.17.0.2) and port (1500).