Search code examples
pythondockervscode-extensionsremote-debuggingvscode-debugger

Vscode breakpoints not being hit when debugging code inside docker container


I am working in a project of a server application which runs inside of a docker container and awaits remote attaching by a debugger. The problem I'm having is that my breakpoints are only hit when I set them through the addition of extra code (Figure 1) but won't get hit when I set them by clicking on the side panel of the code I want to debug (Figure 2) - which is the classical (and desirable) way of doing it. I've spent already countless hours trying to solve the matter to no avail and I really have no idea what else to try. I'm using Vscode v1.74.3, Python v3.8.10 and Python extension for vscode v2022.20.2.

Figure 1

Figure 2

This is the revelant part of my launch.json file:

{
    "name": "Backend attach (Docker)",
    "type": "python",
    "request": "attach",
    "host": "localhost",
    "port": 5678,
    "pathMappings": [
        {
            "localRoot": "${workspaceFolder}/Backend/Src/app",
            "remoteRoot": "/home/backend-server/app"
        }
    ]
}

I'd appreciate any help!


Solution

  • I fixed the problem. It was the path mappings in the end. The code was done by a previous coworker that is not in the team anymore and he had 2 copies of the same project in the container, but set the 'remoteRoot' to the wrong one. Since the codes are still the same, no error is shown but the breakpoints are also not triggered.