Create an Azure virtual host with Docker machine

Source: Internet
Author: User
Tags docker machine

Building an environment has always been a process of repeating wheels, and Docker machine brings together a variety of scenarios for users to build Docker environments. In the article "Introduction to Docker Machine", the author demonstrates the use of Docker machines to install a Docker environment on a local vSphere host. But in the big bang of the cloud today, what really makes us headache is probably a variety of IaaS platforms! This is where Docker machine really does its power.
Docker Machine encapsulates the platform-related parts into different drivers. As long as a driver is provided for an IaaS platform, Docker machine can support operations on that platform. Big vendors like Azure, AWS, GCE, Digitalocean have long been supported. This article will take Azure as an example of using Docker machine to create and manage Docker virtual hosts on the IaaS.

If you do not know about Docker machine, please move to the first two articles of the author to supplement the relevant knowledge: "Docker machine Introduction", "Docker machine detailed".

Prepare

Our goal is to create a virtual host with Docker installed on top of Azure via Docker machine. Because all of the resources on Azure must be licensed using a subscription account, we first have to prepare an Azure subscription account. The domestic Azure has been engaged in a dollar trial activities, go to apply for a bar!

Azure recommends that we organize resources through the resource group. For demonstration convenience, we create a new resource group named Nickcontainer to store the virtual machine that will be created:

There is no content in resource group at this time.

Create cloud Virtual machine

With Docker machine, a create command can be done:

docker-Machine Create--Driver Azure--azure-Environment Azurepubliccloud--azure-subscription-IDxxxxxxxxxxxxxxxxxxxxxxxxxx--azure-location"East Asia"     --azure-size standard_a0--azure-image Canonical:ubuntuserver:16.04.0-lts:latest--azure-SSH-User Nick--azure-resource-Group Nickcontainer--azure-availability-Set Testvmtiggeras Testvmtigger

For users with domestic Azure, change the parameter--azure-environment azurepubliccloud to--azure-environment azurechinacloud.
Executing the above command first verifies that we have access to Azure to do this:

At this time the execution process is stopped, the output is very clear, you need to access the Https://aka.ms/devicelogin in the browser, and then enter a verification code:

Fill in the Verification code and continue:

Enter your subscription account and password here to complete the authentication:

Now that the authentication process is complete, you can turn off the browser. Back to the command line, I found that it went down again. The whole process takes a few minutes, until the following is output:

Let's look at the state of the virtual machine Testvmtigger:

Already in the "runing" state, connect to the Docker daemon to try:

You can see that the server-side version is 17.05.0-ce, much higher than the local client version.

Let's go back to Azure portal and see what's newly created in resource group:

A look startled, why so many things? In fact, the students who have played Azure virtual machine know that when we create a virtual machine, we will create all the resources that this virtual machine relies on, such as storage, virtual network, network security group, availability collection, network card, public IP address and so on. Here we only care about two points (in the red box) is enough: first, the virtual machine was successfully created, and second, all the resources of the region are in East Asia.

After a round of checks, we can determine that the Create command has done a good job of creating a virtual machine on Azure and installing a Docker environment. Let's explain some of the main parameters in the Create command.

Detailed Parameters

--driver Azure
The driver parameter tells Docker machine that the objects we operate on are on the azure cloud and need to be manipulated using azure-related interfaces.

--azure-environment Azurepubliccloud
There are many sets of Azure cloud environments that are independent of each other, such as domestic. So you need to use this parameter to specify the specific Azure cloud environment. The default value is Azurepubliccloud, which points to the Azure International Edition we're talking about. The connecting domestic version needs to be designated as Azurechinacloud.

--azure-subscription-id xxxxxxxxxxxxxxxxxxxxxxxxxx
This is the id,azure of the subscription associated with your account, which is dependent on this ID.

--azure-location "East Asia"
Azure deploys a lot of data centers around the world, and we can specify where the resources are created by location. The location of course is closer to the user the better, the domestic international version of the user choose East Asia a little better.

--azure-size standard_a0
Azuer depending on the size (in fact, the configuration) to charge the virtual machine, the demo selection of the standard_a0 is probably like this:

Although the configuration is not high, but as a demo is enough. MS offers a very rich size to choose from, and if you are creating a virtual machine instance of a production environment, you may need to select an instance of $ dozens of to $ hundreds of per month.

--azure-image Canonical:ubuntuserver:16.04.0-lts:latest
For a production environment, virtual machine mirroring is critical. The Ubuntu server 16.04 image is used in the Demo, and of course we can specify any virtual machine images supported by Azure here. This is much more powerful than using Boot2docker.

--azure-ssh-user Nick
You can log in to the user in the virtual machine via SSH, let's try it:

Directly to the user Nick Login succeeded, in fact, Docker machine has been configured for this user through the secret key login information.

--azure-resource-group Nickcontainer
The resource group to which the newly created resource belongs.

Clear Resources

Docker machine can not only create virtual machines, but also manage virtual machines. is the so-called management only able to stop, start, and restart? The answer is that you can have more features, but you need the support of the relevant driver. For example, the RM command, for the azure driver, it can kill almost all the stuff you just created! Execute the following command:

RM Testvmtigger

This is a very dangerous operation, so there is a step to confirm the execution, and then it really kills the resources on Azure (in addition to the storage section):

Although I think this is really a very strong and cool features, but still want to warn themselves and students: must be cautious use!

Summary

The cloud service opens up a new door for us, and of course it poses many challenges for the ops people. How to choose tools that are friendly to the cloud is an important way to improve our efficiency. Docker machine has done a good job in this direction in terms of docker operations. Sincerely hope that this tool can continue to improve, to become a sword in the hands of operations personnel.

Create an Azure virtual host with Docker machine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.