Connect Docker container to network interface / device instead of IP address

After thorough research, testing and driving, I could only find a Docker container connecting to this interface by forwarding from an IP port. This can be done by adding the -p Host-IP:Host-Port:Container-Port command to the docker run .

I have an application that listens for UDP broadcasts (255.255.255.255) and cannot configure the forwarding so that my container receives these broadcasts without forwarding all network traffic to a port that I am very interested in (no matter through which it included), i.e. -p Host-Port:Container-Port .

You can configure the container using --net=host and just write my code to bind to this interface, which I have made and tested, but this still contradicts the main idea of ​​the container. The goal is for multiple containers of the same application to listen on different network interfaces (as in devices, not in addresses).

Any ideas on how I can do this?

EDIT # 1 : thinking about it, it’s possible that setting up the bridge through the necessary interface is enough, but I don’t trust the OS to send broadcast packets over it. Stay tuned when I run more tests.

EDIT No. 2 . Packets transmitted over the bridge are just fine. However, the bridge is configured as the default docker bridge. I could not understand how to run containers on different bridges. Highlight a few notes that indicate how to configure the network to --net=none and configure it yourself through the settings of the lxc container.

+7
docker udp broadcast raw-sockets
source share
1 answer

By default, docker run displays ports for tcp. Try specifying the use of udp:

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

-one
source share

All Articles