Problems when running a mediasoup-based webrtc server in docker on Mac

I’m running a mediasoup webrtc server in docker on Mac, the main pain points is the dynamic UDP port range mapping,

Dockerfile:

EXPOSE 80/tcp
EXPOSE 443/tcp
#EXPOSE 10000-10100/udp

& I use docker run --env ENV_HOST_IP=100.100.20.20 -p 10000-10010:10000-10010/udp ... to pass the host side’s LAN ip address in:

const local_ip_address = require('ip').address(); //this is a string like "127.17.0.3"
...
      webRtcTransport: {
        listenIps: [
          {
            ip: local_ip_address,
            announcedIp: process.env.ENV_HOST_IP
          }
        ],

When start webrtc server docker instance, I can successfully use gstreamer(in another docker instance) to push RTP stream to it,
But after some time, the nodejs webrtc server script will output the following errors:

 mediasoup:Channel [pid:15] RTC::PlainTransport::OnRtpDataReceived() | ignoring RTP packet from unknown IP:port +39ms
  mediasoup:Channel [pid:15] RTC::PlainTransport::OnRtpDataReceived() | ignoring RTP packet from unknown IP:port +40ms
  mediasoup:Channel [pid:15] RTC::PlainTransport::OnRtpDataReceived() | ignoring RTP packet from unknown IP:port +40ms
  mediasoup:Channel [pid:15] RTC::PlainTransport::OnRtpDataReceived() | ignoring RTP packet from unknown IP:port +40ms
  mediasoup:Channel [pid:15] RTC::PlainTransport::OnRtpDataReceived() | ignoring RTP packet from unknown IP:port +41ms
  mediasoup:Channel [pid:15] RTC::PlainTransport::OnRtpDataReceived() | ignoring RTP packet from unknown IP:port +40ms
  mediasoup:Channel [pid:15] RTC::PlainTransport::OnRtpDataReceived() | ignoring RTP packet from unknown IP:port +39ms
  mediasoup:Channel [pid:15] RTC::PlainTransport::OnRtpDataReceived() | ignoring RTP packet from unknown IP:port +0ms
  mediasoup:Channel [pid:15] RTC::PlainTransport::OnRtpDataReceived() | ignoring RTP packet from unknown IP:port +40ms

So I’m doubting the docker’s UDP port range mapping syntax, but the official documentation doesn’t give much help.

Docker on Mac is problematic, so now i have switched to run mediasoup webrtc server natively: Just use webpack(or ncc) and package the compiled mediasoup-worker binary and I’ve got the prebuilt cross-platform ability.

Trick to override the mediasoup-worker binary file position:

process.env.MEDIASOUP_WORKER_BIN = __dirname + "/bin/mediasoup-worker";
...

Yes you have to publish ports instead of using network host.