Using Visual Studio Running a multi-
container application using Visual Studio 2019 can’t get any simpler. You just press
Ctrl+F5 to run or F5 to debug, as usual, setting up the
docker-compose project as the startup project.
Visual Studio handles all needed setup, so you can create breakpoints as usual and debug what finally
become independent processes running in “remote servers”, with the debugger already attached, just
like that.
As mentioned before, each time you add Docker solution support to a project within a solution, that
project is configured in the global (solution-level) docker-compose.yml file, which lets you run or
debug the whole solution at once. Visual Studio will start one container for each project that has
Docker solution support enabled, and perform all the internal steps for you (dotnet publish, docker
build, etc.).
If you want to take a peek at all the drudgery, take a look at the file:
{root solution folder}\obj\Docker\docker-compose.vs.debug.g.yml
The important point here is that, as shown in Figure 5-12, in Visual Studio 2019 there is an additional
Docker command for the F5 key action. This option lets you run or debug a multi-container
application by running all the containers that are defined in the docker-compose.yml files at the
solution level. The ability to debug multiple-container solutions means that you can set several
breakpoints, each breakpoint in a different project (container), and while debugging from Visual
Studio you will stop at breakpoints defined in different projects and running on different containers.
Figure 5-12. Running multi-container apps in Visual Studio 2022
89
CHAPTER 4 | Development process for Docker-based applications
Additional resources •