Deploying ASP.NET 5 Applications To Docker


This articles introduces the concept of Docker containers and demonstrates how an ASP.NET 5 application can be deployed to an ASP.NET container in a Linux Virtual Machine on Azure.


.NET Core

.NET Core 5 is an open source stack and can run on multiple operating systems.

It is a modular implementation that can be used in several devices, is available as an open source, and is supported by Microsoft on Windows, Linux and Mac OSX.

.NET Core is not specific to either .NET Native nor ASP.NET 5. Therefore, it forms the foundation for all future .NET verticals, even additional to ASP.NET or Windows Store.


ASP.NET 5 is now a single framework that runs on top of either .NET Core 5 runtime (Core-CLR) or the .NET Framework runtime (CLR).

ASP.NET 5 is the first workload that has adopted .NET Core. ASP.NET 5 runs on both the .NET Framework and .NET Core.

A key value of ASP.NET 5 is that it can run on multiple versions of .NET Core 5 on the same machine. Website A and website B can run on two different versions of .NET Core on the same machine, or they can use the same version.


What is Docker?

Docker allows you to package an application with all of its dependencies into a standardized unit for software development.


What are containers?

Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, and system libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in.


How is this different from virtual machines?

Containers have similar resource isolation and allocation benefits as virtual machines but a different architectural approach allows them to be much more portable and efficient.
     Virtual Machines                                                 Docker Containers image


Docker Hub

The Docker Hub is a repository for building and shipping application or service containers. It provides a centralized resource for container image discovery, distribution and change management, and user and team collaboration.

Docker Files

A Docker file is a text file where you tell Docker what you want in your image. It contains all the commands a user could call on the command line to assemble an image. More details about Docker File will come in the next article of this series.

Docker and DevOps

ASP.NET Container Deployment Process

Deploying the ASP.NET App to Docker

Visual Studio 2015

In this article, Visual Studio 2015 shall be used. Click here to download it.

Visual Studio Tools for Docker

The Visual Studio 2015 Tools for Docker Preview enables developers to build and publish an ASP.NET 5 Web or console application to a Docker container running on a Linux or Windows virtual machine.

Click here to download Visual Studio Tools for Docker.

Create an ASP.NET 5 Web Site

To create a new ASP.NET Website, click on File, New Project, then ASP.NET Web Application.

Then under ASP.NET 5 tab, select Web Site.

Deploy the Web Site

Right-Click on the project and click Publish.

If Docker tools have been installed correctly, a new option will appear in the publish window called Docker Containers.

Form here, you may either use an existing container or create a new one.

In this example, a new container shall be created.

Next, fill in the DNS Name, User Name, and password and click OK.

Since no VM was available, a new Ubuntu VM will be provisioned after which we’ll need to publish the Web Site.

Ubuntu VM

The log of the VM creation can also be viewed in Visual Studio.

log of the VM creation

VM creation

Once the VM is created, the Web Site can be deployed. Right-Click on the project and click publish again.

This will automatically select a newly created Docker Profile with all the settings filled.

Click Publish to deploy the Web Site.

Web Site

This will perform all the steps discussed in the previous section and same can be viewed in the log.
  1. Building the project.

    Building the project

  2. Doing a Docker Build.

    Docker Build

  3. Sending the build details to the Docker Daemon.

    build details

  4. Downloading the ASP.NET image from the Docker Hub.

    Docker Hub

    Once the deployment completes, the website will open.

Conclusion & Next Steps

In this article, the basics of Docker was covered, and also demonstrated how easy it is to deploy an ASP.Net Web Site to a Docker image on a Linux VM.

In the next article, more technical details about Docker files, build and deployment via Power Shell shall be discussed.


Similar Articles