Docker Remote Debugging
- in vscode, trigger command "create a launch.json file"
- choose python, then Remote Attach :
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
],
"justMyCode": true // add this to debug libraries
}
]
}
- launch container :
docker compose -f compose.local.yml:compose.local.debug.yml up -d
(or export COMPOSE_FILE=compose.local.yml:compose.local.debug.yml) - add a breakpoint where you need
- on vscode, go to the debug pannel and click on the start button
- got to
localhost:8000
and do the action needed to trigger the breakpoint
source : article