Docker Community Forums

Share and learn in the Docker community.

Dual ISP connection on one computer

Hi I have a Debian 11 (64-Bit) machine which I have installed docker latest and is running in swarm mode. This computer has two physical network connections. One of the network is 192.168.1.1/24 which connects to Frontier internet. And the second network is 172.16.0.1/16 which connects to Xifinity internet. Both connection have internet.

In Docker compose how can I tell my container to use internet from 192.168.1.1 (Frontier ISP) and the other container to use internet from 172.16.0.1 (Xfinity ISP)? In other words choose which container uses which ISP to connect to the internet. All my computers has this setup.

Thank you.

Hi

In your ports section, you can define ip also, like:

ports:
 - 172.16.0.1:8080:80

I don’t know exactly because I haven’t done it but I am pretty sure you cannot do it with only docker compose. In this case you have Docker Swarm, which complicates things more. You can try to configure macvlan networks for your containers but that can cause other issues or you can try to use iptables to change the routing on the host. I am not good at iptables so I can’t give you the final solution.

That is for incoming traffic on a specific host interface. The outgoing traffic still goes on the default route, and if 172.16.0.1 is the ip address of the router (which probably the case) and not the host, Docker will not be able to forward port from that IP.