Last active
February 1, 2016 21:40
-
-
Save Mierdin/a1d803f501bd34137517 to your computer and use it in GitHub Desktop.
A quick script to create a Swarm cluster with Docker Machine on OSX (with configuration for multi-host networking as well)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create | |
docker-machine create -d virtualbox local | |
eval "$(docker-machine env local)" | |
TOKEN_SWARM=$(docker run swarm create) | |
docker-machine create -d virtualbox mh-keystore | |
docker $(docker-machine config mh-keystore) run -d -p "8500:8500" -h "consul" progrium/consul -server -bootstrap | |
CREATE_MASTER_NODE="docker-machine create --engine-opt="cluster-advertise=eth1:2376" --engine-opt="cluster-store=consul://$(docker-machine ip mh-keystore):8500" -d virtualbox --swarm --swarm-master --swarm-discovery token://$TOKEN_SWARM swarm-master" | |
CREATE_NODE_01="docker-machine create --engine-label name=swarm-agent-00 --engine-label storage=ssd --engine-opt="cluster-advertise=eth1:2376" --engine-opt="cluster-store=consul://$(docker-machine ip mh-keystore):8500" -d virtualbox --swarm --swarm-discovery token://$TOKEN_SWARM swarm-agent-00" | |
CREATE_NODE_02="docker-machine create --engine-label name=swarm-agent-01 --engine-label storage=rust --engine-opt="cluster-advertise=eth1:2376" --engine-opt="cluster-store=consul://$(docker-machine ip mh-keystore):8500" -d virtualbox --swarm --swarm-discovery token://$TOKEN_SWARM swarm-agent-01" | |
eval $CREATE_MASTER_NODE | |
eval $CREATE_NODE_01 | |
eval $CREATE_NODE_02 | |
eval $(docker-machine env --swarm swarm-master) | |
# Destroy | |
# WARNING - THESE COMMANDS ASSUME THAT THIS IS YOUR ONLY USE FOR DOCKER MACHINE. | |
# IT WILL DELETE ALL DOCKER MACHINES THAT YOU HAVE PROVISIONED. | |
# (BUT YOU OF COURSE ARE NOT JUST IMPLICITLY RUNNING COMMANDS YOU FOUND ON THE INTERNET...RIGHT?) | |
# docker-machine kill $(docker-machine ls -q) | |
# docker-machine rm -y $(docker-machine ls -q) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment