从Docker容器发送udp广播

编程入门 行业动态 更新时间:2024-10-24 22:23:13
本文介绍了从Docker容器发送udp广播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有几个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广播

本文发布于:2023-10-07 13:00:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469455.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:容器   Docker   udp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!