我的机器上有多个 NIC,因此有多个外部可路由 IP 地址。
当我启动一个容器时,我想让容器的虚拟 eth0 具有我公开可见的 IP 地址之一的 IP 地址
这是因为我的每个应用程序都查询其本地 IP 并通过专有协议(protocol)将其与外部通信,因此所有 iptables 技巧都不起作用
我该怎么做?
最佳答案
我不确定这是否是一个好的做法,但是您可以在启动容器时传递 --net
选项:
docker run --net=host ...
来自 man docker run
:
--net="bridge"
Set the Network mode for the container
'bridge': creates a new network stack for the container on the docker bridge
'none': no networking for this container
'container:': reuses another container network stack
'host': use the host network stack inside the container. Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure.
关于docker - 如何将主机的 IP 地址传递到 Docker 中的容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24925265/