I've a Django app and its dependencies running in docker containers (on Windows 10 with WSL2). This is working fine but I'd like to be able to debug it through PyCharm Pro. Here's my web container in the docker-compose
# The main container - containing the Django code
web:
build: ./web
ports:
- "8000:8000"
depends_on:
- postgres #wait for postgres to be started, not for ready
- redis
- npm_watch
volumes:
- ./web:/usr/src/app
- ./web/collectstatic:/usr/src/app/collectstatic
env_file: .env
environment:
DEBUG: 'true'
LOCAL: 'true'
command: su myuser -c "/usr/local/bin/python manage.py runserver 0.0.0.0:8000"
I configured a Docker Compose interpreter targeting the Django app container and created a Django Server Run/Debug configuration see below (up command option is to have all containers started)
When starting the docker-compose, the web container exits almost immediately with exit code 0. After manually restarting that node, it stays up but visiting the homepage only display a connection error.
When connecting to that container I can see the following process running, but only the port 53240 was listened to. Container is not listening on port 8000
python -u /opt/.pycharm_helpers/pydev/pydevd.py --port 53240 --file /opt/project/web/myproject/settings.py runserver --noreload 0.0.0.0:8000
I also tried to add a Docker configuration but it seems that you cannot debug it (debug bottom panel logs nothing)
Any idea how to make this work ? I couldn't find a lot examples for this kind of setup.
Or is it impossible this way and I need to either use remote debugging with PyDevd or run de Django app outside the docker env ? That would be a bummer ... Would it work on other IDEs like Visual Studio Code ?
Thanks :-)
