- Generate API Key on Digital Ocean, copy locally, set in env variable however you want (export DIGITALOCEAN_ACCESS_TOKEN=xxx)
-
docker-machine create \ --driver digitalocean \ --digitalocean-access-token=$DIGITALOCEAN_ACCESS_TOKEN \ --digitalocean-image=debian-8-x64 \ --digitalocean-region=sfo2 \ --digitalocean-size=1gb \ --digitalocean-ipv6=false \ --digitalocean-private-networking=true \ --digitalocean-backups=true \ --digitalocean-ssh-user=devleague \ --digitalocean-ssh-port=22000 \ --digitalocean-ssh-key-fingerprint=~/.ssh/id_rsa.pub \ devleague-docker-host-01
Note At time of this writing(docker-machine v 0.8.2), if the above fails the host will still be created locally in the ~/.docker/machine/machines directory with the specified host name. You will need to rm -Rf that directory before running the comman again or you will receive: Host already exists: "devleague-docker-host-01"
If everything is successful you can remove hosts via docker-machine rm devleague-docker-host-01
Note At time of this writing(docker-machine v 0.8.2), setting non-standard SSH port with --digitalocean-ssh-port or user --digitalocean-ssh-user failed with a timeout waiting for SSH to be available. Not sure why...
See this page for default settings and default ENV names:
Docker Machine Defaults and ENV variables
Get your DigitalOcean SSH keys:
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $DIGITALOCEAN_ACCESS_TOKEN" "https://api.digitalocean.com/v2/account/keys"
After a droplet has been provisioned you may want to have other scripts or use your own base image with certain base security and configurations since it's a clean OS install.
You can then set your local docker environment with the following command: eval $(docker-machine env devleague-docker-host-01). I set a zsh alias for this.
I didn't know how to set it back initially so I created another alias to unset all ENV settings(DOCKER_TLS_VERIFY, DOCKER_HOST, DOCKER_CERT_PATH, DOCKER_MACHINE_NAME
alias dmlocal= 'eval "$(docker-machine env -u)"'
alias dmhost=dmhost
dmhost() {
eval "$(docker-machine env $1)"
}
Note Important to do this from (this)[https://www.digitalocean.com/community/tutorials/how-to-provision-and-manage-remote-docker-hosts-with-docker-machine-on-ubuntu-16-04] article: touch ~/.docker/machine/no-error-report
Note Overall when things work right it's great but error handling all around and side effects seemed to be prevalent and wide spread in the early stages.