Docker Community Forums

Share and learn in the Docker community.

Routing for docker network

Hello
I have machines HOST-A, HOST-B, HOST-C over a local network.
On HOST-A (Linux Ubuntu) I am running some containers within a docker network.
I need the applications within the containers to talk with applications on HOST-B, HOST-C over UDP, both unicast and multicast.

ping is working by default from the docker containers.
ping is working from HOST-B, HOST-C to the docker network addresses if I add HOST-A as default gw for 172.18.0.0 (docker network).

Unfortunately the communication between the applications on docker containers and the physical hosts doesn’t work.
If I start the containers using “net=host” everything works fine

My understanding is that docker itself adds iptables rules for enabling the communication between the local host and the docker networks, but I can’t understand how these rules would interfere with the simple rule I’d like to add (basically enabling the forwarding of all the UDP packets, don’t want to do natting for the time being)

I have tried to simply add the iptables rule
“sudo iptables -A FORWARD -p udp -j ACCEPT”
But it is not working.

Any suggestion about how to enable the udp communication between my docker and physical network ?

Have you tried just creating your own network with bridge as the driver, and having the containers use that network via --network network?

Default host network does not auto manage ip tables or service discovery. However with user created bridge networks, docker will manage the ip tables and provide service discovery.

Alex,
sorry, I could have not been clear in describing my issue: I have already done what you suggest
All the containers I mention are running within a manually-created docker network (with bridge driver).