gpt4 book ai didi

linux - Docker 容器内的动态监听端口

转载 作者:IT老高 更新时间:2023-10-28 21:39:12 25 4
gpt4 key购买 nike

我有一个应用程序,在使用其默认端口建立一些连接后,它开始打开(监听)新的 RANDOM 端口以仅处理现有连接,然后丢弃它们(视频通话)。

它还在通信协议(protocol)中交换它的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

关于linux - Docker 容器内的动态监听端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35424942/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com