Skip to content

Instantly share code, notes, and snippets.

@mjclemente
Last active March 24, 2021 10:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjclemente/4de6d89f6413ca333757df8ffc0420a1 to your computer and use it in GitHub Desktop.
Save mjclemente/4de6d89f6413ca333757df8ffc0420a1 to your computer and use it in GitHub Desktop.
Create Docker Hosts on DigitalOcean with Docker Machine
#!/bin/bash
#Based on: https://github.com/BretFisher/dogvscat/blob/master/create-servers.sh
#For more details, see: https://blog.mattclemente.com/2018/07/15/create-docker-nodes-on-digitalocean-with-shell-script.html
#Approach without Docker Machine: https://gist.github.com/mjclemente/ada1a591bce5f4fedcd6d6d992d95705
args=(
--driver=digitalocean
--digitalocean-access-token="${DO_TOKEN}"
--digitalocean-ssh-key-fingerprint="${SSH_FINGERPRINT}"
--digitalocean-private-networking=true
--digitalocean-tags=demotag
)
if [[ -n "${DO_SIZE}" ]]; then
args+=( --digitalocean-size="${DO_SIZE}" )
fi
if [[ -n "${DO_IMAGE}" ]]; then
args+=( --digitalocean-image="${DO_IMAGE}" )
fi
if [[ -n "${DO_REGION}" ]]; then
args+=( --digitalocean-region="${DO_REGION}" )
fi
for server in {1..3}; do
docker-machine create "${args[@]}" \
dvc${server} &
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment