UDP packets seem to be filtered

  • Issue type: Networking
  • OS Version/build: macOS Ventura 13.2.1
  • App version: Docker Desktop 4.16.2

My goal is to run a Node application within a Docker container. In the Node application I have set up a UDP socket and binding it to the port 10000 where I expect to receive data. And for the Docker container I have added a port mapping “10000:10000/udp”. I have ~30 Arduino-based devices running a server that continuously send out UDP data about the devices’ state on port 10000. The Node application should be able to read all those UDP data packets and update its objects (each representing one of those devices). Every UDP data packet includes a unique id (for example 1, 2, 3 etc.) of the device so there is no issue to assign the data to the correct object. I should note that this works perfectly when running the application outside of a Docker container.

However, a problem arises when I use a Docker container and I don’t really understand why. When I run
nc -uklvw 0 10000 in a terminal on my Mac, I can see lots of UDP data packets with different device ids. However, when troubleshooting I have started a simple alpine container like this:
docker run -it --rm -p 10000:10000/udp alpine sh
Within this shell I have run nc -ulkp 10000 and the first few UDP data packets that I receive are from different devices (for example 1, 2, 3) but then for some reason it seems to filter it down to only one (for example id 2). And it keeps showing data from just this one device. Cancelling and running nc -ulkp 10000 again will give me the same result but perhaps with another device (for example id 3). Still only one though when I want all 30. The only pattern I have noticed is that it keeps showing data for the one device that it got the first packet from when I started running the nc command.

So yeah, completely out of the loop why this happens. Don’t know if the UDP buffer size is too low but wouldn’t it stop getting new UDP data at all in that case? I just don’t understand why it is seemingly “choosing” one source and keeps showing UDP data from that one. Help much appreciated!