Skip to content

Instantly share code, notes, and snippets.

@bborysenko
Last active May 4, 2018 13:30
Show Gist options
  • Select an option

  • Save bborysenko/ecea3c76975577eb80ea67d0903057d8 to your computer and use it in GitHub Desktop.

Select an option

Save bborysenko/ecea3c76975577eb80ea67d0903057d8 to your computer and use it in GitHub Desktop.
Docker Swarm on Digital Ocean
#!/usr/bin/env bash
export MACHINE_DRIVER="digitalocean"
export DIGITALOCEAN_IMAGE="centos-7-x64"
export DIGITALOCEAN_PRIVATE_NETWORKING="true"
export DIGITALOCEAN_REGION="fra1"
export DIGITALOCEAN_SIZE="s-1vcpu-1gb"
export DIGITALOCEAN_SSH_KEY_FINGERPRINT="56:46:4b:c0:d0:fd:5b:7f:94:91:6d:39:30:ea:ef:df"
export DIGITALOCEAN_MONITORING="true"
docker-machine create node-01
eval $(docker-machine env node-01)
docker swarm init --advertise-addr eth1 --data-path-addr eth1
# Swarm initialized: current node (ac1qf9hu830ezkf0xfsaneuyz) is now a manager.
# To add a worker to this swarm, run the following command:
#
# docker swarm join --token SWMTKN-1-2kgfsxbohlk3qtqqegplm1cmrma05tb9nqjgbdifutzi8il8g7-83c3u0rvhs6ecq8c81n05wqk5 10.135.54.132:2377
#
# To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
for i in {2..3}; do
docker-machine create node-0$i
done
export DOCKER_SWARM_MANAGER_ADDR="$(docker system info --format '{{.Swarm.NodeAddr}}')"
export DOCKER_SWARM_JOIN_TOKEN_WORKER="$(docker swarm join-token worker -q)"
for i in {2..3}; do
eval $(docker-machine env node-0${i})
docker swarm join --token "${DOCKER_SWARM_JOIN_TOKEN_WORKER}" "${DOCKER_SWARM_MANAGER_ADDR}:2377"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment