After careful research, testing, and fiddling, I've only been able to find away to connect a Docker container to a given interface by forwarding from an IP/port. This can be accomplished by adding -p Host-IP:Host-Port:Container-Port
to a docker run
command.
I have an app that listens for UDP broadcasts (255.255.255.255), and have been unable to configure forwarding in such a way that my container will receive those broadcasts without forwarding all network traffic on the port I care about (no matter through which interface it comes in), ie: -p Host-Port:Container-Port
.
It's possible to configure the container with --net=host
and just write my code to bind to a given interface, which I've done and tested, but that still goes against the main idea of a container. The goal is to have multiple containers of the same app listening on different network interfaces (as in devices, not addresses).
Any ideas on how I could do this?
EDIT #1: After thinking about this some more, it may be possible that setting up the bridge over the required interface is enough, but I don't trust the OS to send the broadcast packets over it. Stay tuned as I perform more tests.
EDIT #2: Packets are sent over a bridge just fine. However, the bridge is configured as the Docker default bridge. I haven't been able to figure out how to run containers on different bridges. Saw some notes that point towards setting the network to --net=none
and configuring it yourself through lxc container settings.