7

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.

tryexceptpass
  • 529
  • 5
  • 14

1 Answers1

-2

By default docker run command publishes ports for tcp. Try to specify use of udp:

docker run -p Host-Port:Container-Port/udb ...

  • 1
    The issue is not forwarding ports, it's forwarding data from a specific interface. – tryexceptpass Mar 14 '15 at 18:45
  • What interface do you want to forward? – Bohdan Levchenko Mar 16 '15 at 10:12
  • 1
    I'm using the word "interface" in this case to denote a network device. If I have a system that's dual homed and I only want to provide a service on one of the networks, I haven't found a way to do that. Forwarding data from a particular IP isn't sufficient in the case that I'm using broadcast or multicast packets. – tryexceptpass Mar 19 '15 at 23:02