Running Docker Machine on Digital Ocean

Running Docker Machine on Digital Ocean

Docker Large H Dark

Running Docker Machine on Digital Ocean

Continuing the series on cloud provider examples using Docker machine, up next is Digital Ocean.


As with the other posts here is a diagram of how I view Docker Machine usage.

Docker Machine

For those who don’t have an account already, you can sign get $10 credit with the following link. When you sign up it requires a credit card that won’t be charged unless you run out of your credit. At $0.007 /hour for the small image you have tons of test time ~60 days with a single instance if you left it running the whole time.

Sign up for a free Digital Ocean account with $10 credit →

Once you have signed up you simply need to grab your security token from your digital ocean management page. In order to o create a personal access token under “Apps & API” in the Digital Ocean Control Panel and pass that to docker-machine create with the --digitalocean-access-token option.

Setup a Docker Machine on Digital Ocean

By default the smallest VM from Digitalocean is spun up (which I thought was quite considerate I might add to not sneak in a mainframe and rack up a bill).

As the instructions say, lets eval the new digitalocean host:

While Digital Ocean has been the only cloud I have used so far that requires only one parameter (crypto key), it also has APIs options that enable the granularity that production workloads often require.

Here is a simple example of an additional flag requesting a container with 1GB of memory rather then the 512MB default.

I can’t help but emphasize how much I appreciate a good set of default values initialized by the CSP. The first go around with a provider is typically getting up and running, not high levels of customization. Digital Ocean nailed it with one required parameter.

As we think about docker infra as code, it only makes sense to see that through with our APIs, Dockerfiles and scripts composing the micro architectures by practicing sound software development principles such as constructors, inheritance, DRY, KISS and so on.

Run a Docker Container on the New Machine

Fire up an nginx instance. We will pass the -d or --detach telling the instance to run in the background and release the CLI. -p 80:80 simply says expose the web service of the nginx process on port 80 to the world. That could be mapped to any deisred port such as -p 80:8080 meaning the service would be publicly accessable via port 8080.

Next verify the service you started. First by getting the IP address of the VM you started with docker-machine create.

Next curl the public port you started the service on using the IP address you just retreived:

Now if you want to troubleshoot that instance, simply use docker exec to attach to the host remotely by spawning a bash shell within the instance.

Or start an Ubuntu image and execute a bash shell at runtime.

Note: There are tons of condensed ways to get the CID and run the desired command all in one line. For example:

Follow this link for some more Docker one-liners.

Lastly you can stop with:

And delete the machine with:

Thats it! I was SUPER impressed with Digital Ocean. It was super easy, very fast (de)provisioning and supported all of the docker-machine API calls flawlessly. I was also testing out the Docker Machine 0.3.0-dev build that will be released shortly and it also worked perfectly so kudos all the way around.

This is just scratching the surface of whats possible, take a look at the Docker docs found here


Thanks for stopping by!

About the Author

Brent SalisburyI have over 15 years of experience wearing various hats from, network engineer, architect, devops and software engineer. I currently have the pleasure of working at the company that develops my favorite software I have ever used, Docker. My comments here are my personal thoughts and opinions. More at Brent's BioView all posts by Brent Salisbury →

  1. raymundoraymundo05-15-2015


    thanks for sharing sir!.