Skip to content

Instantly share code, notes, and snippets.

@ajeetraina
Created February 1, 2017 17:45
Show Gist options
  • Save ajeetraina/3abc402f98a4f30173f0ac9902cd8407 to your computer and use it in GitHub Desktop.
Save ajeetraina/3abc402f98a4f30173f0ac9902cd8407 to your computer and use it in GitHub Desktop.
Script to Setup 3 Master and 3 worker nodes
bash-3.2# vi swarm-mode-setup.sh
bash-3.2# chmod +x swarm-mode-setup.sh
bash-3.2# ./swarm-mode-setup.sh
======> Creating 3 manager machines ...
======> Creating manager1 machine ...
Running pre-create checks...
Creating machine...
(manager1) Copying /var/root/.docker/machine/cache/boot2docker.iso to /var/root/.docker/machine/machines/manager1/boot2docker.iso...
(manager1) Creating VirtualBox VM...
(manager1) Creating SSH key...
(manager1) Starting the VM...
(manager1) Check network to re-create if needed...
(manager1) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env manager1
======> Creating manager2 machine ...
Running pre-create checks...
Creating machine...
(manager2) Copying /var/root/.docker/machine/cache/boot2docker.iso to /var/root/.docker/machine/machines/manager2/boot2docker.iso...
(manager2) Creating VirtualBox VM...
(manager2) Creating SSH key...
(manager2) Starting the VM...
(manager2) Check network to re-create if needed...
(manager2) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env manager2
======> Creating manager3 machine ...
Running pre-create checks...
Creating machine...
(manager3) Copying /var/root/.docker/machine/cache/boot2docker.iso to /var/root/.docker/machine/machines/manager3/boot2docker.iso...
(manager3) Creating VirtualBox VM...
(manager3) Creating SSH key...
(manager3) Starting the VM...
(manager3) Check network to re-create if needed...
(manager3) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env manager3
======> Creating 3 worker machines ...
======> Creating worker1 machine ...
Running pre-create checks...
Creating machine...
(worker1) Copying /var/root/.docker/machine/cache/boot2docker.iso to /var/root/.docker/machine/machines/worker1/boot2docker.iso...
(worker1) Creating VirtualBox VM...
(worker1) Creating SSH key...
(worker1) Starting the VM...
(worker1) Check network to re-create if needed...
(worker1) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env worker1
======> Creating worker2 machine ...
Running pre-create checks...
Creating machine...
(worker2) Copying /var/root/.docker/machine/cache/boot2docker.iso to /var/root/.docker/machine/machines/worker2/boot2docker.iso...
(worker2) Creating VirtualBox VM...
(worker2) Creating SSH key...
(worker2) Starting the VM...
(worker2) Check network to re-create if needed...
(worker2) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env worker2
======> Creating worker3 machine ...
Running pre-create checks...
Creating machine...
(worker3) Copying /var/root/.docker/machine/cache/boot2docker.iso to /var/root/.docker/machine/machines/worker3/boot2docker.iso...
(worker3) Creating VirtualBox VM...
(worker3) Creating SSH key...
(worker3) Starting the VM...
(worker3) Check network to re-create if needed...
(worker3) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env worker3
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
manager1 - virtualbox Running tcp://192.168.99.101:2376 v1.13.0
manager2 - virtualbox Running tcp://192.168.99.102:2376 v1.13.0
manager3 - virtualbox Running tcp://192.168.99.103:2376 v1.13.0
master1 * virtualbox Running tcp://192.168.99.100:2376 v1.13.0
worker1 - virtualbox Running tcp://192.168.99.104:2376 v1.13.0
worker2 - virtualbox Running tcp://192.168.99.105:2376 v1.13.0
worker3 - virtualbox Running tcp://192.168.99.106:2376 v1.13.0
======> Initializing first swarm manager ...
Swarm initialized: current node (h9ijgumrzu8lz7ooi0btkaxa7) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join \
--token SWMTKN-1-02c9uy78uie5xvm7jfxxrb77uc5cakz6nosjde37955i0ebp3s-3kqvlxxjufmo6wpvkns03cdbz \
192.168.99.101:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
manager_token: SWMTKN-1-02c9uy78uie5xvm7jfxxrb77uc5cakz6nosjde37955i0ebp3s-8x837z1potadkxx31aqtna6h2
worker_token: SWMTKN-1-02c9uy78uie5xvm7jfxxrb77uc5cakz6nosjde37955i0ebp3s-3kqvlxxjufmo6wpvkns03cdbz
======> manager2 joining swarm as manager ...
This node joined a swarm as a manager.
======> manager3 joining swarm as manager ...
This node joined a swarm as a manager.
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
6v3zdywk8x2jsnvaatufroq7c manager2 Ready Active Reachable
h9ijgumrzu8lz7ooi0btkaxa7 * manager1 Ready Active Leader
wwypko05vj2sf8g64zdmibusm manager3 Ready Active Reachable
======> worker1 joining swarm as worker ...
This node joined a swarm as a worker.
======> worker2 joining swarm as worker ...
This node joined a swarm as a worker.
======> worker3 joining swarm as worker ...
This node joined a swarm as a worker.
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
4gl4dkzn6yn5ea3s7tfbwvvg9 worker2 Ready Active
5grndndyx7m3cs38of3w06vak worker1 Ready Active
6v3zdywk8x2jsnvaatufroq7c manager2 Ready Active Reachable
h9ijgumrzu8lz7ooi0btkaxa7 * manager1 Ready Active Leader
pn3t5h5fqxv99rxaomspjjjhk worker3 Ready Active
wwypko05vj2sf8g64zdmibusm manager3 Ready Active Reachable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment