How to Provision Docker Hosts on Azure using Docker Machine

Docker machine helps you to spin up docker hosts locally as well as with various cloud providers. This tutorial will teach to how to provision docker hosts on azure using docker machine utility.

Prerequisites

1. The system should be configured with azure CLI tools and the publishsetting file. I f you do not have CLI setup, follow this tutorial . How to set up Azure cli 
2. You should have latest docker-machine installed on your system.

Provision Docker Hosts on Azure

Provisioning docker hosts on azure is relatively easy. Docker machine will provision the VM and installs the latest docker engine on the VM based on its OS family. You can then deploy and manage containers from your laptop or host where docker machine is installed.

Creating a host using docker machine

Follow the instructions given below.

Execute the following command to create a docker host on azure using docker machine.

Note: Change id, YOUR-SUBSCRIPTION ID and USER-DEFINED-NAME accordingly. USER-DEFINED-NAME should be a unique name. If you try to use generic names, you will get an error saying that the name already exists.

Example

By default, the docker machine azure driver creates an ubuntu 14.04 host.

To list all the environment variables set by docker machine for accessing the machine you have created, just execute the following command.

READ  How To Setup and Configure Kubernetes Cluster On Google Cloud (GCE)

Output

Now, to run docker commands on your new machine, use the following command.

In your current terminal, you can run all docker commands against the azure docker host.

Moreover, you can create a swarm cluster on azure using docker machine. We will cover that in the next article. Let us know in the comments section if you face any errors.

Free DevOps Resources

Get DevOps news, tutorials and resources in your inbox. A perfect way If you want to get started with devops. Like you, we dont like spam.