Docker Community Forums

Share and learn in the Docker community.

Broadcast not working on Mac (works with Windows)

I have a python application which searches for a device on the network through UDP broadcast packets. My code works well under Windows, MacOS (Darwin), Docker (Windows Host), but not Docker on MacOS (Darwin). Can someone point me in a direction to find and solve the cause.

The Mac IP (and device to be found) has an IP of 192.168.2.x
Normally 192.168.2.255 as a broadcast works

Python Code:
(with various addresses tried for MacOS)

server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
server.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
server.settimeout(0.2)
server.bind(("", 9302))
message = msgpack.packb({“service”: “control.ws”})
a=2
#self.Log.Log("\tLooking for Server:")
while a>1:
#self.Log.Log("\t\tSending broadcast #"+str(a))
server.sendto(message, (Broadcast_Addr, 9101))
print("\t\t…Broadcast to: “, Broadcast_Addr)
time.sleep(1)
try:
data, addr = server.recvfrom(1024)
except socket.error as e:
#self.Log.Log(“Error getting socket data: %s” % e)
self.Log.Log(“Exiting Program Now”)
sys.exit(1)
except:
print(”****Stopped looking - Major Error!")
sys.exit(1)
else:
Server_Data = msgpack.unpackb(data)
#Server was found
pass
a=a-1

Windows Docker call (which works)

docker run -it -p 5000:5000 --name ABC --link DEF -p 8765:8765 -v C:\ABC_Volume:/logs -v /var/run/docker.sock:/var/run/docker.sock -v /usr/local/bin/docker:/usr/bin/docker -p 9101:9101/udp -p 9302:9302/udp --env HostOS=‘Win’ --env HostIP='192.168.2.9 myimage:v1 sh

MacOS Docker call (does not work)*

m$ docker run -it -p 5000:5000 --name SMOR -p 8765:8765 -p 9101:9101/udp -p 9302:9302/udp -v /Users/rpm/ABC:/logs -v /var/run/docker.sock:/var/run/docker.sock -v /usr/local/bin/docker:/usr/bin/docker --env HostOS=‘Mac’ --env HostIP=‘192.168.2.1’–net=bridge myimage.v1 sh

Nobody have any ideas?