I have setup docker manually on windows server 2016 by following this article https://docs.docker.com/ee/docker-ee/windows/docker-ee/
I have two windows server 2016 hyper-v machines sharing the same network and I added firewall rules to allow network connectivity form each one to the other.
The first machine holds the private IP 192.168.192.254 and the other one holds the private IP 192.168.192.242 and they can ping each other.
I have tried to init swarm on the first machine and used the below command docker swarm init --advertise-addr 192.168.192.245:2377 --listen-addr 192.168.192.245:2377
but I got the below error
*
Error response from daemon: manager stopped: failed to listen on remote API address: listen tcp 192.168.192.245:2377: bind: The requested address is not valid in its context.
* I executed the below command then
docker network inspect nat
Looks like the docker has its own interface and its network IP is different than the hyper-v default switch! This means that both dockers on the both machines do not know how to communicate with each other, if my understanding is correct, how can I build multi node swarm with this situation?
The other thing I have tried to do and failed with, is to init the swarm and used an IP address within the range of the docker window but I got the same issue
Edit Again:
Now it worked with this IP:Port 192.168.192.243:2377 and was able to add the first hyper-v VM as a manager node but as you see the other machine can't join the swarm. I have noticed that when I add --listen-addr 192.168.192.243:2377 I get the same error like above.
I have also disabled firewalls on both machines but nothing is working
You need to use one of the host's IP address for listen-addr
because as the name implies it will try to listen on that IP address.
There's advertise-addr
as well as this is the network address advertised to other nodes (they will use that address to connect to the swarm).
In most setups the two will be identical but there are cases where they are different (for example hosts with multiple network cards
might only want the swarm to be reachable in a single network
, or hosts interconnected via VPN
perhaps want the swarm to only communicate via the VPN interface
).
You could theoretically have a swarm manager behind a NAT
interface in which case the advertise-addr would be that of the NAT device (I'm only speculating the NAT case - I haven't tried this).
Anyway using this initialization command should work in your case:
docker swarm init --advertise-addr 192.168.192.242