[英]How do I pass the host's IP address to my container in Docker
I have multiple NICs on my machine and hence multiple externally routable IP addresses. 我的计算机上有多个NIC,因此有多个可外部路由的IP地址。
When I start a container, I want to make the container's virtual eth0 have the IP address of one of my publically visible IP addresses 当我启动容器时,我想让容器的虚拟eth0具有我公开可见的IP地址之一的IP地址
This is because each of my applications queries its local IP and communicates it to the outside over a proprietary protocol, so all of the iptables tricks wont work 这是因为我的每个应用程序都查询其本地IP并通过专有协议将其传递给外部,因此所有的iptables技巧都不会工作
How do I do this? 我该怎么做呢?
I'm not sure if it's a good practice, but you can pass --net
option when you start your container: 我不确定这是不是一个好习惯,但你可以在启动容器时传递
--net
选项:
docker run --net=host ...
From man docker run
: 从
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.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.