Docker容器和独立桌面应用程序中的多播不起作用
我有一个应用程序(UI),该应用程序可以监视多播流以查看流是否正常工作。 最重要的是,我还有一个Docker容器(在“ Network_mode:host”中运行),该容器还倾听了多播流并在数据库中缓存它们。
撰写文件看起来像这样:
version: "3"
services:
my-multicast-container:
image: my-multicast-container-image:latest
depends_on:
- my-database
network_mode: host
my-database:
image: my-database-image:latest
restart: always
ports:
- ... #forwarded ports for the other container
我的问题是:当我收听Docker容器内的多播流时,与Docker在同一主机上运行的监视应用程序无法收听Docker正在听的相同流到。当我在线阅读时,由于容器的工作原理,没有“ Network_mode:host”的码头容器中的多播,而且似乎找不到解决该问题的解决方案。
如何在Docker容器和桌面应用程序中接收多播数据包?
仅供参考:不知道它是否重要,但我正在使用CentOS作为主机OS
I have an application (UI) that monitors multicast streams to see if the streams are working correctly.
On top of that, I have a docker container (that runs in "network_mode: host") that also listens to the multicast streams and cache them in a database.
The compose file looks like this :
version: "3"
services:
my-multicast-container:
image: my-multicast-container-image:latest
depends_on:
- my-database
network_mode: host
my-database:
image: my-database-image:latest
restart: always
ports:
- ... #forwarded ports for the other container
My issue is : when I listen to the multicast streams inside my docker container, the monitoring application that runs on the same host as the docker isn't able to listen to the same streams that the docker is listening to. As I've read online, it's not possible to listen to multicast in a docker container without "network_mode: host" because of how containers works,... and can't seem to find a solution to that problem.
How can I receive the multicast packets in my docker container and in my desktop application ?
FYI: don't know if it's important but I'm using CentOS as a host OS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题并不是真正的多播,而是实际上是关于拥有多播UDP插座的用户。
默认情况下,docker容器的启动为 root 用户,并且监视接口始于主机的用户。并且,如SO_REUSEPORT文档中所述:
因此,为了重复使用套接字,解决方案是使用主机的用户以这样的方式运行Docker容器:
The problem was not really about multicast but, in fact, was about the user which owns the multicast UDP socket.
By default, the docker container is started as root user and the monitoring interface is started with the host's user. And, as mentioned in the SO_REUSEPORT documentation :
So, to re-use the socket, the solution was to use the host's user to run the docker container like this :