Along with much of the software industry, Microsoft is betting on Docker.
The company announced a wide-ranging partnership with Docker back in October, as well as planned integrations with Windows Server and Microsoft Azure. Microsoft is in the process of following through on the Azure front, detailing the four steps needed to run an ASP.NET 5 application in a Linux container with Docker on the Azure cloud.
A recent blog post by Microsoft Azure software engineer Ahmet Alp Balkan lays out a tutorial of how to deploy an ASP.NET 5 application to a Linux Virtual Machine. The steps, resulting in a running application on the Microsoft Azure cloud with Docker on a Linux or Mac OS, are as follows:
Step 1: Create a Linux VM with Docker
Using Docker installation instructions or the Getting Started with Docker on Azure guide, set up a Linux virtual machine on Azure with Docker installed.
Step 2: Create a container image for your app
As Docker container images are layers on top of each other, Balkan explained, the Azure application sits on top of the base image written in ASP.NET. Thus the developer must create a Docker image using Dockerfile in order to set up a small application that will deploy quickly without the Linux distribution or ASP.NET 5 binaries.
Step 3: Build the container image
Once the Dockerfile is ready, Balkan detailed the next step: building a container image using the Dockerfile by executing a myapp command that can be used to build a new image every time the Azure application changes. Following the command, the ASP.NET 5 application should be placed in the list of Docker images and ready for deployment.
Step 4: Run the container
Using the following command in the Azure VM, the developer watches as the Docker container runs in the background with the previously created Docker image:
docker run -t -d -p 80:5004 myapp
All that’s left to do, Balkan explained, is to complete the endpoint port mapping for Azure VM in the Azure Management Portal and check the browser to assure the application is running.