Skip to content

Instantly share code, notes, and snippets.

@arun-gupta
Last active September 27, 2020 17:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save arun-gupta/98a62d8dfcd203089421a5cad7746be4 to your computer and use it in GitHub Desktop.
Save arun-gupta/98a62d8dfcd203089421a5cad7746be4 to your computer and use it in GitHub Desktop.
# Docker Machine for Consul
docker-machine \
create \
-d virtualbox \
consul-machine
# Start Consul
docker $(docker-machine config consul-machine) run -d --restart=always \
-p "8500:8500" \
-h "consul" \
consul -server -bootstrap
# Docker Swarm master
docker-machine \
create \
-d virtualbox \
--swarm \
--swarm-master \
--swarm-discovery="consul://$(docker-machine ip consul-machine):8500/v1/kv/cluster1" \
--engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500/v1/kv/cluster1" \
--engine-opt="cluster-advertise=eth1:2376" \
swarm-master
# Docker Swarm node-01
docker-machine \
create \
-d virtualbox \
--swarm \
--swarm-discovery="consul://$(docker-machine ip consul-machine):8500/v1/kv/cluster1" \
--engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500/v1/kv/cluster1" \
--engine-opt="cluster-advertise=eth1:2376" \
swarm-node-01
# Docker Swarm node-02
docker-machine \
create \
-d virtualbox \
--virtualbox-disk-size "5000" \
--swarm \
--swarm-discovery="consul://$(docker-machine ip consul-machine):8500/v1/kv/cluster1" \
--engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500/v1/kv/cluster1" \
--engine-opt="cluster-advertise=eth1:2376" \
swarm-node-02
# Configure to use Docker Swarm cluster
eval "$(docker-machine env --swarm swarm-master)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment