Docker 容器内的动态监听端口
Dynamic listening ports inside Docker container
我有一个应用程序,在使用其默认端口建立一些连接后,它开始打开(侦听)新的 RANDOM 端口以仅处理现有连接,然后丢弃它们(视频通话)。
它还在通信协议中交换其 IP 地址和端口,我能够解决 IP 地址问题,但仍然无法找到动态告诉主机 IPTABLES 打开相同端口的方法正在 Docker 容器内打开,有人有什么想法吗?
--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
我有一个应用程序,在使用其默认端口建立一些连接后,它开始打开(侦听)新的 RANDOM 端口以仅处理现有连接,然后丢弃它们(视频通话)。
它还在通信协议中交换其 IP 地址和端口,我能够解决 IP 地址问题,但仍然无法找到动态告诉主机 IPTABLES 打开相同端口的方法正在 Docker 容器内打开,有人有什么想法吗?
--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