我有几个Docker容器(使用 docker-compose 和一个网络-network-sol)
I'm having a few docker containers (Using docker-compose and a single network - network-sol)
其中一个容器是 Spring Boot应用程序,该应用程序将UDP广播发送到本地网络。 255.255.255.255失败,因为它是 network-sol
One of the containers is a Spring Boot application that sends UDP broadcast to the local network. 255.255.255.255 fails because It's the local broadcast address of network-sol
的本地广播地址如何广播UDP消息,例如顶级本地网络会得到那些数据包?我是否必须使用定向广播地址?
How can I broadcast UDP messages such as the "top local network" Will get those packets? Do i have to use directed broadcast address for that?
PS
如果应用程序部署在docker(本地网络的一部分)之外,则广播工作>
broadcast works if the application is deployed outside of docker (part of the local network
推荐答案您应该运行 docker-compose.yml 文件中定义的服务使用 network_mode:主机。
You should either run the service defined in your docker-compose.yml file with network_mode: host.
或者,您可以通过发布要与之通信的容器的端口来发布它使用以下配置。请注意,< / udp 是UDP通信正常工作所必需的。
Alternatively you can publish the port of the container you intended to communicate with by publishing it using the following configuration. Note that the /udp is required for UDP communication to work.
service: ports: - "8080:8080/udp"更多推荐
从Docker容器发送udp广播
发布评论