The Microsoft Azure driver

As you may have noticed from the terminal and browser screenshots, so far, we have been using Docker for Mac; let's look at the Microsoft Azure driver using Docker for Windows.

First of all, you will need a Microsoft Azure account; if you don't already have one, you can sign up at https://azure.microsoft.com/. Once you have your account, the only piece of information you need to get started is your subscription ID; you can find this in the billing section of the portal.

Once you have your subscription ID, you can authenticate Docker Machine with Azure, to do this enter the following command, making sure to replace the subscription ID with your own:

docker-machine.exe create --driver azure --azure-subscription-id xxxxxxx-85a6-4ab4-b5c4-c18b54e014
98 azuretest
The Microsoft Azure driver

You will receive an activation code to authorise Docker Machine; go to https://aka.ms/devicelogin/ and enter the code you have been given:

The Microsoft Azure driver

Clicking Continue will take you a page which then shows you the permissions which Docker Machine is going to grant:

The Microsoft Azure driver

Once you click Accept, you should see Docker Machine start bootstrapping the environment. The process will take several minutes; once it completes, you should see something like the following output:

The Microsoft Azure driver

As you can see, Docker Machine has done the following:

  • Created a resource group
  • Configured a network security group
  • Configured a network subnet
  • Created a virtual network
  • Assigned a public IP address
  • Created a network interface
  • Created a storage account
  • Launched a virtual machine

If you go to the resource group within the Azure Portal you should see your virtual machine is launched and ready:

The Microsoft Azure driver

Like the Mac and Linux versions of Docker Machine we need to configure our local Docker client to communicate with the remote host, to do this we need to run the following command:

docker-machine.exe env --shell powershell azuretest | Invoke-Expression

This is the equivalent of running the following on Mac or Linux:

eval $(docker-machine env azuretest)

You can check that Azure is now active by running:

docker-machine.exe ls

Now that we have our client talking to our Azure remote host, we can launch the Hello World container by running:

docker container run hello-world
docker container ls -a

As with the Mac and Linux version of Docker Machine, you can SSH into your Azure host by running:

docker-machine.exe ssh azuretest

As you can see from the output below, we can see the Hello World container:

The Microsoft Azure driver

From here you can interact with the Azure host as you would do any other Docker host. Once you are ready to terminate your Azure host, all you need to do is run the following command:

docker-machine.exe rm azuretest

It will take a short while to remove the host and all the resources associated with it, once complete, you should see something like:

The Microsoft Azure driver

Checking the Activity log in the docker-machine Resource group using the Azure portal should show you the resources being removed:

The Microsoft Azure driver

As highlighted by the PowerShell output, it is best to check that everything has been properly terminated, the easiest way to do this is to remove the resource group itself, to do this click on the three dots (...) on the right-hand side of the docker-machi ne resource.

After you have followed the on-screen prompts, which include typing the name of the resource you are choosing to remove, you should receive confirmation that the resource group has been removed.

While we have used Windows to look at Azure, the process, other than switching the local client to use the remote host, is the same on Mac and Linux.

Note

Please note, this is not Docker for Azure, we will be covering this service in Chapter 4, Docker Swarm.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset