How to provision a windows container in Azure? (Mar 26, 2017)


How to provision a windows container in Azure?

In this article, we will see how to provision a windows container on Azure and how to run a SQL SERVER within a windows container.

A little bit of background, container technology has been implemented in Linux world for many years but it was not as important as now. Docker Inc., a tech company based in SF sponsored the Docker project at 2013 and now millions of developers around the world are using this amazing technology on their daily job for a faster software shipment. Microsoft recently has included container support in Windows Server 2016 and higher versions in the form of Windows Containers.

First, we need to deploy a Windows Server 2016 with Containers on Azure. In order to work on Azure portal, you need an azure account and once you sign up you will get $250 credit (The credit amount may change in the future) which is more than enough for provisioning a windows container.

After the login to Azure portal, we need to add Windows Server 2016 with Containers.

windows server 2016

 

Click on Windows Server 2016 Datacenter with Containers.

 

windows server 2016

 

Click on Create.

 

windows server 2016

 

In this step we need to provide details of the VM e.g. name, disk type, user name and password. Click Ok to select the size next.

 

windows server 2016

 

Here select the size that fits your requirement. I have the first option selected.

 

windows server 2016

 

Step 3 requires more details e.g. Storage, Network etc. Click Ok after providing all necessary items.

 

windows server 2016

 

After viewing the summary click Ok. At this stage, Azure starts deploying the VM.

 

windows server 2016

 

 It may take a couple of minutes and after deployment you will see the successful notification in the portal.

 

windows server 2016

 Now, our VM is up and running and we can RDP to it by clicking on the Connect button to download the RDP connection information.

 

windows server 2016

 

After logging into the VM, click Windows Power Shell.

 

windows server 2016

 

In the PowerShell console, type docker version and press ENTER to see docker server and docker client version.

 

windows server 2016

 As you can see docker server OS/Arch is Windows/amd64. There are some images that comes with Windows Server 2016 with Containers on Azure e.g. windowsservercore

 

windows server 2016

 Now, in order to run SQL SERVER on a Windows Container we need to pull the image from docker hub.

 

windows server 2016

 

After couple of minutes, pulling SQL SERVER will be completed.

 

windows server 2016

 

In the PowerShell console type docker images and press ENTER to see installed image.

 

windows server 2016

Now that we have pull the image, let’s run it using below command and defined parameters:

docker run -it -p 1433:1433 -e sa_password=P@ssw0rd -e ACCEPT_EULA=Y microsoft/mssql-server-windows-express

 

windows server 2016

 

After couple of seconds our SQL SERVER is up and running in a Windows Container.

 

windows server 2016

Let’s run docker ps command to get the list of running containers.

 

windows server 2016

 So, as you can see our container is up and running. Now let me show you how to connect to this container from your local machine using SQL SERVER STUDIO MANAGEMENT. We need to open port 1433 to windows server 2016 VM in Azure in order to connect to the database.

 This article show how to open a port in azure VM and you would open port 1433.

After opening the port you can login to the database in the container using SQL SERVER MANGEMETNT STUDIO.

 

windows server 2016

 Now, let me stop the container.

 

windows server 2016

And I am getting a network error when running a query to the database.

 

windows server 2016

 

To sum up, in this article, we saw how to provision a windows container on Azure and how to run a SQL SERVER within a windows container.

Back to All Articles

Number of Views:597