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 #20607

Closed
eladavron opened this issue Jan 31, 2023 · 5 comments
Closed

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

eladavron opened this issue Jan 31, 2023 · 5 comments
Assignees
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@eladavron
Copy link

eladavron commented Jan 31, 2023

Type: Bug

I'm opening this here as well as in the Docker Extension GitHub as per their recommendation:

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.

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 Docker extension
  • Downgrading Docker extension

Versions:

  • VSCode: 1.74.3
  • Docker Desktop: 4.16.2
  • Python Extension: 2022.20.2
  • Extension: 1.23.3

Extension version: 2022.20.2
VS Code version: Code 1.74.3 (97dec172d3256f8ca4bfb2143f3f76b503ca0534, 2023-01-09T16:59:02.252Z)
OS version: Windows_NT x64 10.0.25284
Modes:
Sandboxed: No
Remote OS version: Linux x64 5.15.83.1-microsoft-standard-WSL2

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Jan 31, 2023
@paulacamargo25
Copy link

Hi @eladavron, could you check if it works if you set "clientOS": "Windows"(or "clientOS": "Unix" if it's the other way around) in your launch configuration (just to make sure this is actually the issue you're seeing and whether it fixes it for you?) Thanks

@paulacamargo25 paulacamargo25 added the info-needed Issue requires more information from poster label Feb 2, 2023
@eladavron
Copy link
Author

The clientOS settings didn't fix it. I didn't have it at all, tried setting it to either Windows or Unix and neither solved the issue.

@paulacamargo25 paulacamargo25 removed the info-needed Issue requires more information from poster label Feb 9, 2023
@eladavron
Copy link
Author

Any updates?

@eladavron
Copy link
Author

P.S. this just started happening on my other device as well.

@eladavron
Copy link
Author

Update: Resolved by microsoft/vscode-docker#3641

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

2 participants