Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Container: UDP Communication with other hosts

i am writing a python application that is sending continously UDP messages to a predefined network with other hosts and fixed IPs. I wrote the python application and dockerized it. The application works fine in the docker, no problems there.

Unfortunately i am failing to send the UDP messages from my docker to the host so they will be sent to the other hosts in the network. The same is for receiving messages. Right now i dont know how to set up my docker so it is receiving a UDP message from a host with fixed IP adress in the network.

I tried to set up my docker network with --net host and i sent all the UDP messages from my docker container via localhost to my host. This worked fine, too. I am missing the link where i can sent the messages no to the "outside world". I tried to make a picture of my problem.

Docker host communication problem

My Question: How do i have to set up the network communcation for my docker/host so it can receive messages via UDP from other hosts in the network? Thanks

like image 293
bumbumquietsch Avatar asked Jan 25 '19 06:01

bumbumquietsch


1 Answers

So i experimented a lot and i figured out, that i just need to run the docker container with the network configuration as host. The UDP socket in my container is bound to the IP adress of my host and therefore just needs to be linked to the Network of the host. Everyone who is struggeling the same issue, just run

docker run --network=host <YOURCONTAINER>
like image 77
bumbumquietsch Avatar answered Sep 19 '22 11:09

bumbumquietsch