Create your first Docker container with an ASP.NET web app

Add Docker Support to your web app

In the Solution Explorer, right-click the myFirstContainerApp project, point to Add, and select Docker Support.

Add Docker Support from Solution Explorer

Make sure that Windows is selected and click OK.

Windows Docker Support

Visual Studio creates a Dockerfile for you, which defines how to create the container image for your web app project. It also creates a docker-compose project, which defines how to build and run your containerized solution.

Right click on the docker-compose project and click Set as StartUp Project.

Set docker-compose project as startup project

Now, when you start your project, it will run inside a Docker container, rather than in IIS Express on your workstation. Try it out by clicking the Docker button on the toolbar.

Start application inside Docker container

Visual Studio will build and run your container image, and launch a web browser showing your web app running inside the newly created container, rather than locally on your workstation.

Application running inside a container

To use the Docker command line tools to verify that your container is running, click the Windows Start button and type cmd to launch a command prompt. Then type docker container ls.

docker container ls output

Congratulations, your ASP.NET web app is now running inside a Docker container.


I ran into an issue My web app is running in a Docker container