How to provision an Ubuntu machine in Microsoft Azure using Docker Machine?
In this blog post, I am goign to show you how to interact with docker machien to provision an Ubuntu machine on Azure.
Docker Machine is another tool in Docker Toolbox that we can use to create and manage local machines and also it can be used to create and manage machines on the cloud e.g. on Azure, AWS or other cloud providers.
In order to interact with Docker Machine, we need Docker Machine to be installed in our local machine.
If you are on Mac or Windows, you need to install Docker for Mac or Docker for Windows. If you are a windows user that your system does not satisfy Docker for Windows requirement e.g. have windows 7, your choice is to install docker machine. Here is the link on how to install Docker Machine on your computer.
There are many Docker Machine driver plugins for cloud platforms, so you can use Docker Machine to provision cloud hosts. When you run a Docker Machine command for provisioning, you actually create cloud host with Docker Engine installed on it.
Now that you have docker machine installed and running, you need to have Azure subscription and then you provide account verification, security credentials, and configuration options for the providers as flags to docker-machine create.
Let’s do this inaction next.
If you are in windows open Docker Quick start Terminal. If you are on Linux or Mac, open a terminal. Type below command:
docker-machine create --driver azure --azure-subscription-id <subs-id> <machine-name>
Please note that docker-machine create command has lots of other options e.g. size. For a list of all options please refer to this link. You will get this:
The output asks you to open a browser and navigate to the provided address and then in the page enter the given code to authenticate to Azure. This is the page after browsing to the address:
Now after entering the code from the terminal, you should be getting below page:
Click on Continue button and then it asks you for entering email address associated to your azure account:
Upon successful authentication, it would ask you to give permission to docker machine to run commands.
Click on accept button and you would get the confirmation page.
Back to the terminal output, there is an error. The reason for the error is that the name for the VM is not valid and using uppercase character is not allowed.
After entering a valid name for the VM, it starts provisioning the VM and it takes a minute to complete.
You can run the following command to get details on this new VM on Azure:
Let’s take a look at Azure portal and see the result of running this docker machine command:
As you can see, running docker machine create command created all these resources for us in the azure portal.
Number of Views:1594