https://github.com/microsoft/vscode-docker/blob/master/resources/python/launcher.py
This file has a section of args that are passed to docker exec.
dockerExecArgs = ['docker', 'exec', '-d', containerId, 'python', '/debugpy/launcher'] + args
My debug fails, because the container receives python as python2.7, but my program needs python3, which is available in the container. If i change this launcher.py file to python3 it works. Can i pass this somehow to the launcher?
@dwbelliston What Python base image are you using? I'm surprised there are any where python maps to Python2.7...
Here is the dockerfile and launch.json.
The base image from docker file is here: https://hub.docker.com/r/google/cloud-sdk/dockerfile
Dockerfile:
# https://github.com/GoogleCloudPlatform/cloud-sdk-docker
# Image provides: gcloud, gsutil, bq, python and more
FROM gcr.io/google.com/cloudsdktool/cloud-sdk:latest
COPY requirements.txt /opt/src/
RUN pip3 install -r /opt/src/requirements.txt
COPY src/ /opt/src
WORKDIR /opt/src/
CMD ["python3", "main.py"]
launch.json
{
"name": "Docker:Raw",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run:raw",
"platform": "python",
"python": {
"pathMappings": [
{
"localRoot": "${workspaceFolder}/raw/src",
"remoteRoot": "/opt/src"
}
],
"projectType": "general"
}
}
Thanks! It looks like that image indeed uses 2.7 as the default. I think we can safely change launcher.py in our extension to use python3 since that works on python:3.8-slim-buster as expected.
As a workaround before we can get that fixed, you can make the same change to launcher.py in the Docker extension's resources.
Windows: %USERPROFILE%\.vscode\extensions\ms-azuretools.vscode-docker-1.3.1\resources\python\launcher.py
Mac/Linux: ~/.vscode/extensions/ms-azuretools.vscode-docker-1.3.1/resources/python/launcher.py
Change python to python3 in dockerExecArgs on line 17.
Alternatively, you could make a copy of that file and use the debugLauncherPath property in the launch config, but that's probably _more_ work.
We have released Docker 1.4.0 which contains a fix for this.