How to add Docker support to your ASP.NET Core application


Well, here we go.  Not only have I had the opportunity to work with open source and Linux, now I get some taste of containers.  I find the concept very interesting because containers solve many issues when in the context of cloud hosting and running code on a multitenant platform.  This is how I added Docker support in Visual Studio.  My plan is to publish this to and Azure App Service, Web App for Containers using a Windows OS.  I.e. Docker on Windows.

See some of my other Docker articles here:

First, you need to make sure you have both the .NET Core cross-platform development and Azure development workloads installed, Figure 1.

image

Figure 1, how to create a Docker on Windows container for publish to an Azure App Service Web App for Containers

You can install these workloads using the Visual Studio installer, Figure 2.

image

Figure 2, how to create a Docker on Windows container for publish to an Azure App Service Web App for Containers

If you already have a project created, right-click the project, select Add –> Docker Support as seen in Figure 3.

image

Figure 3, how to create a Docker on Windows container for publish to an Azure App Service Web App for Containers

Select the OS target, Figure 4 and press OK.

image

Figure 4, how to create a Docker on Windows container for publish to an Azure App Service Web App for Containers

If you are creating a new project then you enable the Docker support, as seen in Figure 5.  Note that you need to install the Docker for Windows and a Docker Hub Account to publish the image to Docker Hub so that it can be later published to an Azure App Service Web App for Containers.

image

Figure 5, how to create a Docker on Windows container for publish to an Azure App Service Web App for Containers

Once created, press F6 to build the project and you are all set.  Read here, “Publish a Docker Windows image to Docker Hub using Visual Studio” on how to now publish the image to Docker Hub.

Comments (0)

Skip to main content