我有一个应用程序,它在使用默认端口建立一些连接后,会开始打开(监听)新的随机端口来处理现有的连接,然后关闭它们(视频通话)。
它还在通信协议中交换其IP地址和端口,我已经解决了IP地址问题,但仍然无法找到一种方法,在Docker容器内部打开相同的端口时,动态地告诉主机机器的IPTABLES。有人有什么想法吗?
--net=host
选项是docker run
命令中的一个参数,可以实现您所需的行为——请注意,它被认为是不安全的,但我真的没有看到其他做法。docker run
手册页面: --net="bridge"
Set the Network mode for the container
'bridge': create a network stack on the default Docker bridge
'none': no networking
'container:<name|id>': reuse another container's network stack
'host': use the Docker host network stack. Note: the host mode gives the container full access to local system services such as D-bus
and is therefore considered insecure.
'<network-name>|<network-id>': connect to a user-defined network