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 Linux is selected and click OK.

Linux Docker Support

Visual Studio creates a Dockerfile for you, which defines how to create the container image for your web app 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

Hint: If you don’t see the Docker button on the toolbar, and you have a docker-compose project in Solution Explorer, then right click on the docker-compose project and click Set as StartUp Project.

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