Hosting Docker Container on Azure Linux VMS

Docker is one of the most popular container management platform amongst the IT companies and it has the capability of running on both Linux and Windows based systems. As it was originally designed for the linux based systems, it’s been the first choice for the DevOps guys to host their containers on the linux systems.

Now there are multiple ways of hosting your container on Azure but we are going to work with the Azure Docker VM Extension as it’s one of the cleanest plug and play solution with Azure IAAS and it helps you to setup the docker while creating your Azure Infrastructure itself.

The Azure VM extensions install the tools like Docker Compose, Docker Daemon and Docker Client. You can run your workloads on the docker container or setup the whole cluster as per your requirements.

Unfortunately, as of today, this extension is not available directly the azure portal but it is easy to setup with the ARM Template.  Let’s go through the template first that we are going to deploy.

 


Â
        “publisher”: “Microsoft.Azure.Extensions”,
        “type”: “DockerExtension”,
        “typeHandlerVersion”: “1.0”,
        “autoUpgradeMinorVersion”: true,
        “settings”: {}
      }

 

 

You can deploy this template via Github template by clicking on the deploy to azure button.

 

Fill in the Information about your VM. All the fields are mandatory to deploy the VM. You can also edit the template/params according to your need or else Azure will create the default values associated with the params you have provided for the VM.

Once the Deployment is completed, you will be able to see the resource created in that specific resource group. You will have a total of 5 resrouces – VM, Disk, Network Interface, Public Ip Address and a virtual Network.

Open the VM and copy the IP mentioned in the overview section of the VM. Open SSH client like Putty to connect to your VM. Fill in the details to ssh into your machine.

Enter your credentials that you have setup while creating the VM.

Once Connected, Check if the docker is setup already and working by running the command

 

docker -v or docker –version

 

 

If the above commands give you the version number that means you’re good to go. You can now work on the docker container and run your container.

 

docker run -d -p 80:80 –restart=always nginx

 

 

We now try to run a simple nginx server on port 80 and exposing it on public port 80. As it’s a fresh VM, so the azure VM won’t  have nginx image on local so it will pull it from dockerhub.

Now as the nginx server is properly setup and its running on port 80. You can hit the IP or the DNS (can be found on azure portal) on the web browser to see your application running.

Summary

Running a docker container on Azure is pretty easy with PAAS and IAAS solution. We have ARM templates which can be easily deployed and the Infrastructure can be ready in minutes with docker up and running.

Comments

comments

Leave a Reply

Your email address will not be published.