Debugging .NET Core Applications in Docker with Visual Studio
This article explains how to set up a Docker‑based development and debugging environment for .NET Core applications using Visual Studio, covering installation of Docker for Windows, required extensions, Dockerfile and docker‑compose configuration, and step‑by‑step container debugging on Azure.
The author needed to develop a portable Web API for a client using .NET Core and Docker, and chose Azure as the deployment platform to satisfy DevOps and portability requirements.
To configure the development environment, Docker for Windows must be installed (requires 64‑bit Windows 10 Pro/Enterprise/Education), along with the Visual Studio .NET Core and Docker extensions. Visual Studio 2015 can be used with these extensions, while VS 2017 includes them natively.
After creating an ASP.NET Core project, Docker support is added via Project → Add → Docker Support , which generates the necessary Dockerfile and docker‑compose files.
FROM microsoft/aspnetcore:1.0.1 ENTRYPOINT ["dotnet", "TestApp.dll"] ARG source=. WORKDIR /app EXPOSE 80 COPY $source .
The docker‑compose file defines the service, image, build context, and port mapping:
version: '2' services: testapp: image: user/testapp${TAG} build: context: . dockerfile: Dockerfile ports: - "80"
When debugging, Visual Studio launches the container, builds the image (e.g., user/testapp:dev ), creates a container, and maps the container’s port 80 to a random host port (e.g., 32769). The debugger attaches automatically, allowing breakpoints to be hit inside the container.
Running docker ps shows the active container, confirming that the application is executing inside Docker. The article demonstrates modifying the Home controller to display the container’s hostname, proving the code runs within the container rather than on the host machine.
Overall, the guide shows how Docker simplifies .NET Core development and debugging, enabling developers to work with just the OS, Docker, and an IDE, and highlights the benefits of container‑based DevOps workflows.
DevOps
Share premium content and events on trends, applications, and practices in development efficiency, AI and related technologies. The IDCF International DevOps Coach Federation trains end‑to‑end development‑efficiency talent, linking high‑performance organizations and individuals to achieve excellence.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.