Skip to content

Instantly share code, notes, and snippets.

@mjclemente
Last active March 19, 2021 15:30
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/ada1a591bce5f4fedcd6d6d992d95705 to your computer and use it in GitHub Desktop.
Save mjclemente/ada1a591bce5f4fedcd6d6d992d95705 to your computer and use it in GitHub Desktop.
Create Docker Hosts on DigitalOcean with doctl
#!/bin/bash
#For more details, see: https://blog.mattclemente.com/2019/03/04/script-docker-host-creation-digitalocean-doctl.html
DO_DROPLET_NAME=docker-node
DO_SIZE=s-1vcpu-1gb
DO_REGION=nyc1
DO_SSH_IDS=$(doctl compute ssh-key list --no-header --format ID)
DO_TAGS=demotag
DO_DROPLET_COUNT=3
: "${DO_SSH_IDS:?Please set your DO_SSH_IDS}"
for server in {1..$DO_DROPLET_COUNT}; do
doctl compute droplet create $DO_DROPLET_NAME-${server} --size $DO_SIZE --image docker-18-04 --region $DO_REGION --ssh-keys $DO_SSH_IDS --tag-names $DO_TAGS --enable-backups --enable-monitoring --enable-private-networking --wait
done
unset DO_DROPLET_NAME
unset DO_SIZE
unset DO_REGION
unset DO_SSH_IDS
unset DO_TAGS
unset DO_DROPLET_COUNT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment