Andrew
Andrew

Reputation: 51

Run docker swarm mode on windows 10 using multiple hosts

I'm running Windows 10 with the latest updates installed. I'm trying to set up a swarm using multiple physical hosts running docker Linux containers on windows host. When I'm running

docker swarm init --advertise-addr 10.154.26.150 --listen-addr 10.154.26.150:2377

Where

10.154.26.150

stands for physical address of my current machine (future swarm manager) I obviously receive

Error response from daemon:
manager stopped:
failed to listen on remote API address: listen tcp 10.154.26.150:2377 
bind: cannot assign requested address

because docker for Windows running Linux containers uses hyper-v vm and doesn't know anything about address I'm trying to specify. So here is a question if there is any small possibility to run swarm mode in this situation so that my other hosts will be able to join new swarm over physical network.

Upvotes: 3

Views: 2792

Answers (1)

Bret Fisher
Bret Fisher

Reputation: 8596

If you're using "Docker for Windows", which runs a Moby VM in Hyper-V and simulates localhost, then it's easy for a single node Swarm setup. It's not yet designed to easily join outside machines.

If you want to have a 3-node swarm to spread out your testing, where they all have easy direct access to each other, then I recommend using docker-machine to create 3 more VM's in Hyper-V running boot2docker, like so:

docker-machine create --driver hyperv --hyperv-virtual-switch "Primary Virtual Switch" node1
docker-machine create --driver hyperv --hyperv-virtual-switch "Primary Virtual Switch" node2
docker-machine create --driver hyperv --hyperv-virtual-switch "Primary Virtual Switch" node3

NOTE: For this to work, 1. Be sure you're in PowerShell admin mode so docker-machine can control Hyper-V and 2. You'll need to create an "external" Hyper-V Switch and use its name in creating the VM's.

Details on the switch setup, and other options like changing CPU and memory are in the docker-machine docs.

Then you can change your docker CLI to control each one directly with & docker-machine env nodeX | Invoke-Expression and ssh into them with docker-machine ssh nodeX etc.

I use this setup and it works great!

Upvotes: 4

Related Questions