Using Docker Machine to Provision on Microsoft Azure

Using Docker Machine to Provision on Microsoft Azure

Docker Microsoft Azure Banner


Using Docker Machine to Provision on Microsoft Azure

Microsoft has done a pretty amazing job with Azure over the years. It has been really cool seeing Microsoft embrace Docker and open source in general like they recently have. This post is a continuation of the series on docker machine provisioning to dev hypervisors, DC infra and cloud providers. If you are new to Azure or don’t have an account, you can grab a free trial from Azure.


Here is a quick diagram overviewing Docker Machine, more on docker and docker machine in the excellent docs at docs.docker.com

Docker Machine

Docker Machine Azure Setup

The following is covered in detail on the docker-machine docs page

Those operations will leave you with three new files:

Next head to the Azure portal, go to the “Settings” at the bottom left of the page, followed by “Management Certificates” and upload mycert.cer.

Note: The docker-machine example is structured to be run from the same directory as the credential files we just created (mycert.pfx mycert.pem mycert.cer).

Next start the docker host machine in the Azure cloud with the following command.

Take a look at the host you created:

You can also get more information on the connection and cert locations using docker-machine config


Next lets fire up a container and have a look around using docker exec to open a shell to the container running at the CSP, in this case Azure:

Exec into a shell on the new container and lets grab the public address of the instance:

Now you can delete the container with:

Deleting machines is similar with docker-machine rm . All of the cloud providers I have added so far support deleting the machine except for one that I had to remove it from the provider’s console. Azure and AWS do support stopping and starting also.


Now you can freely switch between CSPs, your private on prem cloud or your local dev environment with a single line. Pretty awesome.

Note – When you switch between active hosts you also need to swap out your ENVs by simply running the eval command and passing the desired instance.

Now I am back in an EC2 host we setup in the next tutorial.

I was super impressed by Docker/Azure integration, this was a breeze to setup. Once again, this is beta and there are still peices getting polished.

Being able to context switch between providers without pain, feels like an important gate in the evolution of computing. The docker machine harness coupled with the dead simple UX for consuming virtually any cloud, public or private, opens the doors to some new patterns in cloud consumption that seemed far off not too long ago.

Troubleshooting

The MS xplat-cli client can be used if you have any issues getting attached to Azure with your account or to get another view at your resources. Credit to the Azure experience, I didn’t need to use it once.

Make sure to use a very unique name for your docker machine in the azure cloud or else you will overlap in the default domain they advertise your hostname as the DNS prefix e.g. ‘machine-name12345.cloudapp.net’. If you have overlap, you will notice an error like the one here:

Thats about it. Super easy, a real testament to all involved. I also have handful of use cases, mostly around network metrics, validation and data collection that I will be using docker-machine as a base for if you want to follow along with me from home.

If you are also starting to use docker-machine and get stuck on something, check out the open and closed issue on the project’s github issues page. Anything I had questions on were already covered in issues and the folks working on the project are top notch and super friendly.


For more from Microsoft, there were some cool announcements of Azure features this week at MS Build.
Azure Docker Extensions Templates →


Next up is Docker Machine and AWS Usage →

About the Author

Brent SalisburyI have over 20 years of experience wearing various hats from, network engineer, architect, ops and software engineer. More at Brent's LinkedInView all posts by Brent Salisbury →