sending udp broadcast from a docker container

两盒软妹~` 提交于 2019-12-05 17:42:52

问题


I'm having a few docker containers (Using docker-compose and a single network - 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

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?

P.S

broadcast works if the application is deployed outside of docker (part of the local network


回答1:


You should either run the service defined in your docker-compose.yml file with network_mode: host.

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"


来源:https://stackoverflow.com/questions/50508833/sending-udp-broadcast-from-a-docker-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!