Use multiple specific network interfaces with docker swarm
Asked Answered
I

1

7

I am using docker swarm to deploy an on-premise third party application. The machine I am deploying on is running RHEL 7.6 and has two network interfaces. The users will interact with the application from eth0, but internal communication with their system must use eth1 or the connection will be blocked by their firewalls. My application requires some of my services to establish connections internal services in their network.

I created my swarm using:

$ docker swarm init --advertise-addr x.x.x.x

Where x.x.x.x is the eth0 inet address. This works for incoming user traffic to the service. However, when I try to establish connections to another service the connection times out, blocked by the firewall.

Outside of docker, on the machine, I can run:

ssh -b y.y.y.y user@server

Where y.y.y.y is the eth1 inet address, and it works. When I run the same in my docker swarm container I get this error:

bind: y.y.y.y: Cannot assign requested address

Is there some way I can use multiple network interfaces with docker swarm and specify which one is used within containers? I couldn't find much documentation on this. Do I need to set up some sort of proxy?

Inductive answered 8/7, 2019 at 14:34 Comment(2)
Why not use the --data-path-addr as mentioned in docs.docker.com/v17.09/engine/swarm/networking/…Sarmatia
Unfortunately, I am trying to connect between two nodes. Both of them can run totally independently, the connection is just a non-blocking background process. If I make them part of the same swarm they will both go down if one of them goes down. Is there a way I can change this behavior? I know it's not a good setup but I really don't have any choice in that.Inductive
T
0

By default, Docker creates a bridged network from the network interfaces on your machine and then attaches each container instance to it via a separate virtual interface internally. So you would not be able to bind to eth1 directly as your Docker container has a different interface.

See https://docs.docker.com/v17.09/engine/userguide/networking/ for a general guide and https://docs.docker.com/v17.09/engine/userguide/networking/default_network/custom-docker0/ for custom bridged networks with multiple physical interfaces.

Tzar answered 25/7, 2019 at 21:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.