Pycharm Not Running Using command from docker-compose.yml

I am trying to run a debug session for a containerized Django app and am running into issues with setting up. the docker-compose virtual environment as well as getting Pycharm to start docker container with my custom run command.


When I setup the docker-compose virtual environment the wizard asks for a python interpreter and defaults to the system interpreter (python3).  There is a drop down for existing virtual environments but the list is empty even though I do have a virtual environment constructed for the existing project.  Even so, when setting up the docker-compose venv I just select the default which in my case is /usr/bin/python3.  I assume this is ok and the correct interpreter to go with even though I would prefer to specify the python binary from my existing virtualenv.

Also, in my docker-compose.yml I specify the command that needs to run and is as follows:

command: >
bash -c "/bin/berglas exec -- python migrate && /bin/berglas exec -- python runserver"

When I create my django server run configuration I specify the docker-compose virtual environment, but when I initiate the run configuration, it doesn't execute my command specified in the docker-compose.yml.  It starts the app with a plain vanilla `python runserver`.  Maybe this is how the tooling works for Django Server run configurations but I need to be able to start the server with this command, `/bin/berglas exec -- python runserver`. 


The key part is the berglas exec --.  Is there anyway to do this in Pycharm.  I cannot seem to find where I can modify the start command that Pycharm uses in the Container based run configuration.

PyCharm 2022.2.2 (Professional Edition)

Please sign in to leave a comment.