How to create a droplet from docker-machine

Posted July 26, 2016 6.3k views

A few weeks ago, I created a droplet using docker-machine by following these articles as my guide:

Everything worked fine and I was able to see the droplet on my dashboard.

Since then I upgraded from Mountain Lion to El Capitan and re-installed docker toolbox. I don’t recall the versions of docker the docker toolbox loaded previously, but now I’m using:

docker-machine version 0.7.0, build a650a40

docker-compose version 1.7.1, build 0a9ab35
docker-py version: 1.8.1
CPython version: 2.7.9
OpenSSL version: OpenSSL 1.0.1j 15 Oct 2014

docker version
Version: 1.11.2
API version: 1.23
Go version: go1.5.4
Git commit: b9f10c9
Built: Wed Jun 1 21:20:08 2016
OS/Arch: darwin/amd64

Now, when I try to create a new droplet using docker-machine I get the following error:

docker-machine create –driver digitalocean –digitalocean-access-token xxxxx docker-sandbox
Running pre-create checks…
Creating machine…
(docker-sandbox) Creating SSH key…
(docker-sandbox) Creating Digital Ocean droplet…
Error creating machine: Error in driver during machine creation: POST 422 You specified an invalid image for Droplet creation.

Has something changed in the DigitalOcean API in the last few weeks that now causes this command to fail? Does El Capitan not support this ability with Docker? Or, am I missing some important component when I did the re-install?

I sure would like to be able to use this capability, as it seems like it would be very beneficial.

Thanks in advance for any assistance you can offer.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

There has not been any recent change to the create API endpoint that could cause this issue. From the output provided the actual error coming from DigitalOcean is

422 You specified an invalid image for Droplet creation.

This means that the DigitalOcean disk image specified could not be used. This value can either be an image slug like ubuntu-14-04-x64 for our stock Ubuntu 14.04 image or docker for our Docker One-Click image or it can be an image ID number which can identify a snapshot image on your account. There are a few reasons this error could happen.

1.) The image specified does not exist.

2.) The image specified does not exist in the data center you have specified (you can move an image to more regions from the Images section of the control panel)

3.) The image specified does not belong to the account you are using (an image can be transferred to a new account from the Images section of the control panel if needed).

  • Thanks for the reply, Ryan. Although I didn’t mention it in the question I posted yesterday, I had already tested launching this by adding an option for –digitalocean-image ubuntu-14-04-x64, but for some reason I still got an error, however, it was different than the one I listed above.

    But, when I executed the following command today it worked:

    docker-machine create –driver digitalocean –digitalocean-access-token xxxxx –digitalocean-image docker docker-sandbox

    So, I guess for whatever reason, I can no longer create a droplet without an image option as I did a few weeks ago.

    Thanks for you help.

    • This may be related to the issue that was fixed here. While in this case it was the Ubuntu 15.10 image, it appears that docker-machine had a hardcoded image ID in it that was causing issues.