6

I am using docker compose and hypriotos on a raspberry pi running a node container. I would like to receive udp multicast messages send to 239.255.255.250:1982 in local network. My code is working on other machines outside of docker so I think it's a docker issue.

I already exposed port 1982/udp in the docker file and in the docker-compose file I added "1982:1982" and "239.255.255.250:1982:1982/udp" to ports. I still can't receive anything. Am I missing something?

My concrete plan is to receive advertisement messages from a yeelight. These messages are documented here

Any help would be nice. Thanks.

leiropi
  • 404
  • 1
  • 4
  • 17

1 Answers1

7

While you can do udp with -p 1982:1982/udp I don't believe docker's port forwarding currently supports multicast. You may have better luck if you disable the userland proxy on the daemon (dockerd --userland-proxy=false ...), but that's just a guess.

The fast/easy solution, while removing some of the isolation, is to use the host network with docker run --net=host ....

BMitch
  • 231,797
  • 42
  • 475
  • 450
  • 1
    Thanks, I'm using the host network now and it works. I had to set the "network_mode" option in the docker-compose file. – leiropi Feb 24 '17 at 14:21
  • 1
    @daniel17903 could you share the config that could make docker container receiving udp broadcast from host? – fatfatson Nov 19 '18 at 07:23
  • 1
    The port forwarding solution (without needing to disable the user land proxy on the daemon) works fine for me on Docker 19.03.5 on Linux. – rgov Jan 15 '20 at 21:36
  • @rgov curious if that with multicast packets, or normal unicast/udp packets. – BMitch Jan 15 '20 at 21:47
  • @BMitch The packets are being sent to 192.168.1.255 and received by 192.168.1.100. – rgov Jan 15 '20 at 21:58
  • @rgov gotcha, that's subnet broadcast, which is diff from multicast, but still good to know. Thanks! – BMitch Jan 15 '20 at 22:04
  • 1
    I can confirm that a UDP multicast sender/receiver node.js app in a docker container does **not** work when running a default `docker run` command with no additional options, but running with `--net=host` makes it work. – Wyck Apr 26 '21 at 18:34
  • @BMitch any idea on how to make it works on Windows machine ? Since Windows does not support the '--net=host' – asnawi Feb 10 '22 at 00:22
  • @asnawi maybe wsl2? Never tried, just running Linux directly here. – BMitch Feb 10 '22 at 00:28