Skip to content

Commit

Permalink
Adding in Docker for Windows support (docker#59)
Browse files Browse the repository at this point in the history
* adding a powershell/hyperv version of the bash scripts for Docker for Windows users. Also cleaned up the documentation

* Update README.md

* Update README.md
  • Loading branch information
Mano Marks authored Sep 30, 2016
1 parent 82ef9a0 commit dddf316
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
4 changes: 3 additions & 1 deletion swarm-mode/beginner-tutorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ You need to have Docker and Docker Machine installed on your system. [Download D
>
* If you are using Docker for Mac or Docker for Windows, you already have Docker Machine, as it is installed with those applications. See [Download Docker for Mac](https://docs.docker.com/docker-for-mac/#/download-docker-for-mac) and [Download Docker for Windows](https://docs.docker.com/docker-for-windows/#/download-docker-for-windows) for install options and details on what gets installed.
>
* If you are using Docker for Windows you will need to use the Hypver-V driver for Docker Machine. That will require a bit more set-up. See the [Microsoft Hyper-V driver documentation](https://docs.docker.com/machine/drivers/hyper-v/) for directions on setting it up.
>
* If you are using Docker directly on a Linux system, you will need to [install Docker Machine](https://docs.docker.com/machine/install-machine/) (after installing [Docker Engine](https://docs.docker.com/engine/installation/linux/)).

## Creating the nodes and Swarm
Expand All @@ -16,7 +18,7 @@ You need to have Docker and Docker Machine installed on your system. [Download D
* Provision and manage multiple remote Docker hosts
* Provision Swarm clusters

But it can also be used to create multiple nodes on your local machine. There's a [bash script](https://github.com/ManoMarks/labs/blob/master/swarm-mode/beginner-tutorial/swarm-node-vbox-setup.sh) in this repository that does just that and creates a swarm. Let's walk through the different steps of this script.
But it can also be used to create multiple nodes on your local machine. There's a [bash script](https://github.com/docker/labs/blob/master/swarm-mode/beginner-tutorial/swarm-node-vbox-setup.sh) in this repository that does just that and creates a swarm. There's also [a powershell Hyper-V version](https://github.com/docker/labs/blob/master/swarm-mode/beginner-tutorial/swarm-node-hyperv-setup.ps1). On this page we're walking through the bash script, but the steps, aside from set-up, are a basically the same for the Hyper-V version.

This first step creates three machines, and names the machines manager1, manager2, and manager3
```
Expand Down
49 changes: 49 additions & 0 deletions swarm-mode/beginner-tutorial/swarm-node-hyperv-setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Swarm mode using Docker Machine

$managers=3
$workers=3
$SwitchName = "New Virtual Switch"

# create manager machines
echo "======> Creating manager machines ..."
for ($node=1;$node -le $managers;$node++) {
echo "======> Creating manager$node machine ..."
docker-machine create -d hyperv --hyperv-virtual-switch $SwitchName ('manager'+$node)
}

# create worker machines
echo "======> Creating worker machines ..."
for ($node=1;$node -le $workers;$node++) {
echo "======> Creating worker$node machine ..."
docker-machine create -d hyperv --hyperv-virtual-switch $SwitchName ('worker'+$node)
}

# list all machines
docker-machine ls
echo "======> Initializing first swarm manager ..."
$manager1ip = docker-machine ip manager1

docker-machine ssh manager1 "docker swarm init --listen-addr $manager1ip --advertise-addr $manager1ip"

# get manager and worker tokens
$managertoken = docker-machine ssh manager1 "docker swarm join-token manager -q"
$workertoken = docker-machine ssh manager1 "docker swarm join-token worker -q"

# other masters join swarm
for ($node=2;$node -le $managers;$node++) {
echo "======> manager$node joining swarm as manager ..."
$nodeip = docker-machine ip manager$node
docker-machine ssh "manager$node" "docker swarm join --token $managertoken --listen-addr $nodeip --advertise-addr $nodeip $manager1ip"
}
# show members of swarm
docker-machine ssh manager1 "docker node ls"

# workers join swarm
for ($node=1;$node -le $workers;$node++) {
echo "======> "worker$node" joining swarm as worker ..."

docker-machine ssh "worker$node" "docker swarm join --token $workertoken --listen-addr $nodeip --advertise-addr $nodeip $manager1ip"
}

# show members of swarm
docker-machine ssh manager1 "docker node ls"
2 changes: 2 additions & 0 deletions swarm-mode/beginner-tutorial/swarm-node-hyperv-teardown.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker-machine stop (docker-machine ls -q)
docker-machine rm --force (docker-machine ls -q)
4 changes: 2 additions & 2 deletions swarm-mode/beginner-tutorial/swarm-node-vbox-teardown.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Stop machines
docker-machine stop worker1 worker2 worker3 manager1 manager2 manager3
docker-machine stop $(docker-machine ls -q)

# remove machines
docker-machine rm worker1 worker2 worker3 manager1 manager2 manager3
docker-machine rm $(docker-machine ls -q)

0 comments on commit dddf316

Please sign in to comment.