Running and debugging an ASP.NET Core RC2 application in Docker


In a previous post I demonstrated how we can run and test an ASP.NET Core RC1 application. Yesterday RC2 was made public and it is now time to revisit the subject. This time we are going to create an ASP.NET Core RC2 MVC application, Docker-ize it and analyze how we can run and debug this application.


Please follow the instructions here to install RC2 of .NET Core and ASP.NET Core as well as the necessary tooling support. Once you have installed RC2 please make sure to also install the Visual Studio Extension Docker Tools for Visual Studio 2015 – Preview that provides first class Docker support. You can find this extension here.

Finally please make sure that you have the Docker Toolbox installed.

Create an application

Start Visual Studio and create a new ASP.NET Web Core Web Application. Let’s call the solution HelloRC2 and the project Web.

Select Web Application as template

So far so good. Let’s try to run this application locally on our developer machine. Select Web as target and press F5 to start the application. After compiling Visual Studio will start Kestrel (the new lightweight Microsoft Web Server) in a console window. It will also open a browser window at localhost:5000. By default Kestrel listens at port 5000.

If the browser reports an error This site can’t be reached then you might need to hit refresh since Kestrel was not starting up fast enough and thus was not ready to serve the request from the browser.

Wonderful, we have our ASP.NET Core application up and running. But this is not so exciting because it’s what we have done all the time… Thus let’s come to the more fascinating part, running the application in a Docker container.

Add Docker support

In the Solution Explorer right click on the Web project and select Add from the context menu. From the sub-menu select Docker Support. A folder called Docker will be added to our project containing a few interesting files. In addition to that the extension also adds two support files to the Properties folder. These are needed to provide the seamless integration of building, running and debugging Docker containers from within Visual Studio.

With that we’re ready to start…

Run and debug the application

Make sure you select Docker as target

Hit F5 to start the application. If you observe the Output window while the application is building you will notice that the script DockerTask.ps1 that was added to the Docker folder is executed. This script will do the following

  • build the application
  • publish the application
  • create a Docker image using the published application
  • create and run a container from the above image
  • start a browser page listening at [IP address] (where [IP address] corresponds to the IP address of your Docker host. In most cases this is

As a result you should see your Web application running inside a container. The look and feel of the application in the browser is exactly the same as when we were running it directly on our developer machine

While building the container image the script has also added remote debugging support into the image. Thus we should be able to start a debugging session. Let’s do this now. Add a break point to line 18 of the HomeController. Now in the application select the About menu and observe how the debugger stops at the break point. We can now observe the content of variables or step through the code line by line – exactly the same way as we’re used when we’re debugging an application running directly on our developer box.


In this post I have demonstrated how we can create an ASP.NET Core RC2 MVC application, deploy the application into a Docker container and remote debug the application running in the container.

Given the fact, that the tooling support is only in Preview 1 I am sure that once it is finalized we will have first class support for Docker containers from within Visual Studio. This is really exciting!

Windows Docker Containers