I managed to debug an asp .net core 3.1 application within an Ubuntu WSL-2 distro (on Windows 10), using a docker-compose file thanks to this Vs code tutorial
But considering we start the container using a docker-compose up command, then we attach the debugger, all breakpoints set in Program.cs or Startup.cs are not hit. Indeed the app has already pocessed these files when I manually attach the debugger, it's too late.
All other breakpoints (in controllers or background process ...) are correctly hit.
When debugging the same project with Visual Studio 2019 Community, all my breakpoints are hit, even those in Program.cs or Startup.cs which is the expected behavior here.
What am I doing wrong ?
The breakpoint l.44 is never hit

- docker-compose.debug.yml (launched by
docker-compose -f "docker-compose.debug.yml" up -d --build)
version: '3.7'
services:
myapp:
image: myapp
container_name: myapp
build:
context: .
dockerfile: src/MyApp/src/Dockerfile
ports:
- "60713:80"
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:80
volumes:
- ~/.vsdbg:/remote_debugger:rw
networks:
default:
external:
name: mynetwork
- launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Docker .NET Core Attach (Preview)",
"containerName": "myapp",
"type": "docker",
"request": "attach",
"platform": "netCore",
"sourceFileMap": {
"/src": "${workspaceFolder}"
}
}
]
}
Indeed if I launch the VS code debugger before the container is up, I get the following error message
Error: Process 'docker exec -i "myapp...' exited with code 1
Error: Error: No such container: myapp
