I'm trying to debug my Docker Django app with this configuration.
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Docker: Python - Django",
"type": "python",
"request": "attach",
"connect": {
"port": 5678,
"host": "0.0.0.0",
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/project"
}
],
"django": true,
"justMyCode": false
}
}
docker-compose.debug.yml.py:
...
django:
extends:
file: docker-compose.yml
service: django
command: sh -c "DEBUG_MODE=True python manage.py runserver 0.0.0.0:8000 --noreload"
ports:
- "5678:5678"
manage.py:
...
if os.environ.get("DEBUG_MODE", False):
import debugpy
debugpy.listen(("0.0.0.0", 5678))
debugpy.wait_for_client()
I run docker compose with the debug file, the program waits to execute the vscode configuration but when I go to url the execution does not stop at the breakpoint.
Output:
Debugger warning: It seems that frozen modules are being used, which may make the debugger miss breakpoints. Please pass -Xfrozen_modules=off to python to disable frozen modules.
Changing the command sh -c "DEBUG_MODE=True python -Xfrozen_modules=off manage.py runserver 0.0.0.0:8000 --noreload"doesn´t work either.
Any sugestion?