Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm debugging manage.py commands in docker compose

I have a pretty simple setup. I'm running Pycharm 2018.2.3 and using docker compose to spin up 3 containers.

  1. My Django application
  2. NGINX to serve static
  3. Postgres DB

I've configured the remote interpreter for debugging the container, and break point work just fine in most cases, at least when I hit my API endpoints or some other action to the django application.

What does not work, is when I run one of my manage custom manage.py custom commands. I've tried this 2 ways so far.

  1. I setup another debug configuration in PyCharm to execute the command. This results in another container spinning up (in place of the original. Running the command, without breaking on any line breaks. Then the whole container shuts down.

  2. I've logged into the container, run the manage.py command directly via the command line, and it execute in the container, but again no breakpoints.

The documentation seems to work in the normal case, but I can't find any help for debugging these commands in the container.

Thanks for any help or tips.

like image 802
G. Ball Avatar asked Nov 07 '22 02:11

G. Ball


1 Answers

In order to debug Django commands in a Docker Container you can create a new Run/Debug Configuration with following setup

  1. Use a Python configuration template
  2. Script path: absolut location of manage.py
  3. Parameters: the Django command you want to debug/execute
  4. !important! Python interpreter: Docker Compose interpreter

enter image description here

enter image description here

like image 113
Stelian Avatar answered Nov 14 '22 21:11

Stelian