Example code on how to run a Django app in a docker container and debug it with VSCode python debugger.
Full explanation at https://medium.com/@davivc/debugging-django-python-dockerized-applications-ff8ba843e6dd
These commands will build, migrate and start the example Django application
docker-compose build
docker-compose up
In a new terminal run
docker-compose exec example python manage.py migrate --noinput
Go to http://localhost:8000/
To debug the application just run the service on debug mode (stop the service started previously to avoid port conflict).
docker-compose up example-debug
Attach the Vscode Python Debugger defined on launch.json
.
Add some breakpoints and start debugging.