Skip to content

Instantly share code, notes, and snippets.

@DaMitchell
Last active May 19, 2016 17:23
Show Gist options
  • Save DaMitchell/ba66a0bcacc289f1417d7af3c0b099cd to your computer and use it in GitHub Desktop.
Save DaMitchell/ba66a0bcacc289f1417d7af3c0b099cd to your computer and use it in GitHub Desktop.
#!/bin/bash
#set -x
VIRTUALBOX_DISK_SIZE="1500"
# Docker Machine for Consul
docker-machine \
create \
-d virtualbox \
--virtualbox-disk-size $VIRTUALBOX_DISK_SIZE \
consul-machine
# Start Consul
docker $(docker-machine config consul-machine) run -d --restart=always \
-p "8500:8500" \
-h "consul" \
progrium/consul -server -bootstrap
# Docker Swarm master
docker-machine \
create \
-d virtualbox \
--virtualbox-disk-size $VIRTUALBOX_DISK_SIZE \
--swarm \
--swarm-master \
--swarm-discovery="consul://$(docker-machine ip consul-machine):8500" \
--engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500" \
--engine-opt="cluster-advertise=eth1:2376" \
swarm-master
# Docker Swarm node-01
docker-machine \
create \
-d virtualbox \
--virtualbox-disk-size $VIRTUALBOX_DISK_SIZE \
--swarm \
--swarm-discovery="consul://$(docker-machine ip consul-machine):8500" \
--engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500" \
--engine-opt="cluster-advertise=eth1:2376" \
swarm-node-01
# Docker Swarm node-02
docker-machine \
create \
-d virtualbox \
--virtualbox-disk-size $VIRTUALBOX_DISK_SIZE \
--swarm \
--swarm-discovery="consul://$(docker-machine ip consul-machine):8500" \
--engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500" \
--engine-opt="cluster-advertise=eth1:2376" \
swarm-node-02
# Configure to use Docker Swarm cluster
eval $(docker-machine env --swarm swarm-master)
#!/bin/bash
#set -x
docker-machine stop consul-machine && docker-machine remove consul-machine
docker-machine stop swarm-master && docker-machine remove swarm-master
docker-machine stop swarm-node-01 && docker-machine remove swarm-node-01
docker-machine stop swarm-node-02 && docker-machine remove swarm-node-02
@DaMitchell
Copy link
Author

Taken from docker/community#57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment