I am running C# in latest version of VS 2019 (Pro) on latest Windows 10 (Pro)
I converted my project (using MS Assistant) from Net Framework to Net 5.0.
All works well -> until I containerize.
Pre-containerization: My process architecture:
Logger TseLogger
Search engine shard 1 of 2 (TseShard -shardId 0)
Search engine shard 2 of 2 (TseShard -shardId 1)
Note that the 'shard' code is the identical code. The distinction is the 'shardId' run-time parameter.
In my solution I want to start 1 logger and 2 shards.
I could not figure out how to tell VS to start 2 copies of the same project (each with its own runtime parameters) so (as a kludge so I could test it) I cloned the TseShard project into 'TseShard 2' project and added it to the list of projects to start.
I could now set breakpoints anywhere in the code and debug (single-step as needed).
I am happy as a pig-in-you-know-what.
Next step was to containerize the projects.
So I want to generate 2 images Logger (TseLogger) Search engine shard (TseShard)
And, from the images, generate 3 containers: 1 logger and 2 shards.
I added Orchestration (docker-compose) support to my solution and Docker support to my TseLogger and TseShard projects.
I edited the auto-generate (by VS 2019) docker-compose.yml file:
version: '3.4'
services:
tselogger:
image: ${DOCKER_REGISTRY-}tselogger-2-3-0-6
build:
context: .
dockerfile: TseLogger/Dockerfile
tseshard0:
image: ${DOCKER_REGISTRY-}tseshard0-2-3-0-6
build:
context: .
dockerfile: TseShard/Dockerfile
ports: [52949]
volumes:
- d:/MyData:/MyData
command: -shardId 0
tseshard1:
image: ${DOCKER_REGISTRY-}tseshard1-2-3-0-6
build:
context: .
dockerfile: TseShard/Dockerfile
ports: [52950]
volumes:
- d:/MyData:/MyData
command: -shardId 1
Note that I added the suffix '-2-3-0-6' (code assembly version) to the images.
Note also that I named the shard services as 'tseshard0' and 'tseshard1'
My expectation is that it allows me to keep images of different code versions so Production can run a stable release while Dev will run new (test) releases.
My expectation is that I can reuse the same docker image (based on docker build of TseShard/Dockerfile) for both shards.
Anyway, it builds (seemingly correct).
For all its worth, the auto-generated (by VS) TseShard/Docker file (I did not edit this one):
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["TseShard/TseShard.csproj", "TseShard/"]
COPY ["Utils/Utils.csproj", "Utils/"]
COPY ["BinarySerialization/BinarySerialization.csproj", "BinarySerialization/"]
COPY ["Interfaces/Interfaces.csproj", "Interfaces/"]
COPY ["JsonCompare/JsonCompare.csproj", "JsonCompare/"]
COPY ["Networking/Networking.csproj", "Networking/"]
COPY ["FilterScoring/FilterScoring.csproj", "FilterScoring/"]
COPY ["DataAccess/DataAccess.csproj", "DataAccess/"]
COPY ["TseClient/TseClient.csproj", "TseClient/"]
RUN dotnet restore "TseShard/TseShard.csproj"
COPY . .
WORKDIR "/src/TseShard"
RUN dotnet build "TseShard.csproj" -c Debug -o /app/build
FROM build AS publish
RUN dotnet publish "TseShard.csproj" -c Debug -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "TseShard.dll"]
I set breakpoints at 'Main' for the logger and the shard code C# modules.
Finally, I start the docker-compose project.
It builds properly (so it seems).
Issue #1: I get an error message box from VS saying: Can not find the container with the name starting with 'TseShard' (see image below)
Issue #2: I'm not sure why it is looking for a container named 'TseShard' (which is the project name, not the image name, and not the service name).
Issue #3: The Output window from Container Tools shows:
========== Debugging ==========
docker ps --filter "status=running" --filter "label=com.docker.compose.service" --filter "name=^/TseShard$" --format {{.ID}} -n 1
========== Debugging ==========
docker ps --filter "status=running" --filter "label=com.docker.compose.service" --filter "name=^/TseShard$" --format {{.ID}} -n 1
Clearly the 'docker ps' is filtering on "name=^/TseShard$" which is looking for exactly 'TseShard'.
But I only defined services for TseShard0 and TseShard1.
See attached images.
Docker shows that the Logger is still running, and the two shards exited.
For sure, I did not reach a breakpoint (at the literal start of 'Main').
I would appreciate any help in setting up the debugging correctly so that I could set break points.
I am ultimately planning to get this to work on Linux 2 on AWS.
Many thanks in advance.

