Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't start debug on dockerized Python app in WSL #3817

Closed
eladavron opened this issue Jan 29, 2023 · 2 comments
Closed

Can't start debug on dockerized Python app in WSL #3817

eladavron opened this issue Jan 29, 2023 · 2 comments

Comments

@eladavron
Copy link

eladavron commented Jan 29, 2023

Similar to #2641 and #2313 but adding "debugAdapterHost": "172.17.0.1" or "debugAdapterHost": "localhost" did not solve it for me.

When I try starting a debug session of a dockerized Python Flask app in WSL, in the exact same configuration that used to work flawlessly, starting ~1 week ago it instead shows me this error after a few seconds:

image

I do see it starting both the container:

 *  Executing task: docker-run: debug 

> docker container run --detach --tty --name 'wifidrvpotatofarm-dev' --publish '443:8080/tcp' --mount 'type=bind,source=/home/eavron/.vscode-server/extensions/ms-python.python-2022.20.2/pythonFiles/lib/python/debugpy,destination=/debugpy,readonly' --label 'com.microsoft.created-by=visual-studio-code' --entrypoint 'python3' wifidrvpotatofarm:latest <

8041342216b01346e9bd6cf643d429a7f77d8d7f6bee35ff96039a50759ac492 *  Terminal will be reused by tasks, press any key to close it. 

and the debugpy session:

eavron@eavron-mobl:/mnt/c/Users/eavron/AppData/Local/Programs/Microsoft VS Code$  /usr/bin/env /bin/python /home/eavron/.vscode-server/extensions/ms-azuretools.vscode-docker-1.23.3/resources/python/launcher.py 41979 -- /app/server.py docker wifidrvpotatofarm-dev 
docker exec -d wifidrvpotatofarm-dev python3 /debugpy/launcher host.docker.internal:41979 -- /app/server.py
eavron@eavron-mobl:/mnt/c/Users/eavron/AppData/Local/Programs/Microsoft VS Code$

but it just doesn't seem to be able to connect to the running container (which remains up even after this error):

eavron@eavron-mobl:/mnt/c/Users/eavron/AppData/Local/Programs/Microsoft VS Code$ docker ps
CONTAINER ID   IMAGE                      COMMAND     CREATED         STATUS         PORTS                   NAMES
9d7947e54110   wifidrvpotatofarm:latest   "python3"   2 minutes ago   Up 2 minutes   0.0.0.0:443->8080/tcp   wifidrvpotatofarm-dev

Running the container regularly with its docker-compose works fine.

Here are my launch.json:

{
    "name": "PotatoFarm Debug",
    "type": "docker",
    "request": "launch",
    "preLaunchTask": "docker-run: debug",
    "python": {
        "pathMappings": [
            {
                "localRoot": "${workspaceFolder}/app",
                "remoteRoot": "/app"
            }
        ],
        "projectType": "flask"
    }
}

and tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "docker-build",
            "label": "docker-build",
            "platform": "python",
            "dockerBuild": {
                "dockerfile": "${workspaceFolder}/Dockerfile",
                "context": "${workspaceFolder}"
            },
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "type": "docker-run",
            "label": "docker-run: debug",
            "dockerRun": {
                "ports": [
                    {
                        "containerPort": 8080,
                        "hostPort": 443,
                        "protocol": "tcp"
                    }
                ]
            },
            "python": {
                "file": "/app/server.py"
            }
        }
    ]
}

Things I've tried that didn't help:

  • Adding "debugAdapterHost": "172.17.0.1" or `"debugAdapterHost": "localhost"
  • Rebuilding the image
  • Clearing Docker cache
  • Reinstalling Docker
  • Reinstalling extension
  • Downgrading extension

Versions:

  • VSCode: 1.74.3
  • Docker Desktop: 4.16.2
  • Extension: 1.23.3
@bwateratmsft
Copy link
Collaborator

It seems like the Docker extension finished its part and did the handoff to the Python extension (which does the actual debugging). I've seen this error happen on occasion, but never persistently. I'll take a look and see if I can reproduce, but it might be worth opening this in https://github.com/microsoft/vscode-python as well; they know much more about Python's debugging process than I do.

@dbreshears
Copy link
Member

Closing for now as this appears to be an issue in the Python extension. Can re-open if that is not the case.

@bwateratmsft bwateratmsft closed this as not planned Won't fix, can't repro, duplicate, stale Feb 1, 2023
@microsoft microsoft locked and limited conversation to collaborators Mar 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants