Part 4 - Containerize .NET App in Visual Studio
In this task we will containerize the application in Visual Studio using Docker compose.
1. Let’s start by adding Docker support to our project. Right-click the project and select Add -> Container Orchestrator Support. Leave the default value for Docker Compose and click OK.
2. Visual Studio has now added Docker Compose support to our project and a Docker file. If you read through the Output window you will notice that docker has also started a container and is running the application inside that container locally on the dev server.
3. Let’s take a quick look at the docker container that is running locally and let’s also browse to the application that’s running inside the container to verify that it’s working as expected. Open a Command Prompt as an administrator and enter the following docker command: docker ps
The docker ps command lists the running Docker processes or containers. We should see that one container is running on the dev server. Now let’s take a closer look at this container by entering the following command: docker inspect <CONTAINER ID>
You only need to enter enough of the CONTAINER ID value for docker to be able to uniquely identify the container. In my case the commands looked like this:
4. Near the bottom of the output from the docker inspect command it will list the IP address of the container. Let’s grab the IP address, open a browser and verify the application is running correctly from within the docker container.
Congratulations you have containerized a .NET application using Visual Studio and Docker. In the next task we will push the container (containing our application) to your Elastic Container Registry (ECR) on AWS.