Try to debug the Python code in Container using VS Code Remote Container Extension.
After the docker build task, I got a "Debug Adapter Executable not provide" error. Where could be wrong?
launch.json
{
"configurations": [
{
"name": "Docker: Python - General",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"python": {
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
],
"projectType": "general"
}
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "docker-build",
"label": "docker-build",
"platform": "python",
"dockerBuild": {
"tag": "py:latest",
"dockerfile": "${workspaceFolder}/Dockerfile",
"context": "${workspaceFolder}",
"pull": true
}
},
{
"type": "docker-run",
"label": "docker-run: debug",
"dependsOn": [
"docker-build"
],
"python": {
"file": "app.py"
}
}
]
}
2
Answers
I also encountered this problem. After trying a fresh install of the VS Code Docker extension, to no avail, I noticed the actually command being triggered by the
"docker-run: debug"
task in thetasks.json
:The key here is the
-v
command that is attempting to mount the/debugpy
files into the container from the VS Code Python extension files.For some reason, those files were not actually located at that path on my Mac. Deleting the
ms-python.python-2022.12.0/
folder and reinstalling the VS Code Python extension solved the issue for me.Looks like it is resolved if you define a local python interpreter even if you want to use docker. Open a .py file and define it with the button right bottom.