Attaching to a docker container.
I have just started using the Docker integration but have a query.
I am developing a Django app and have setup the Python interpreter to be in a docker container, this is setup from a docker compose file. Running and debugging is working fine for this.
I was wondering if there is any way to attach to one of the docker containers from the Django run/debug configuration as you can when using the docker compose run/debug configuration.
Please sign in to leave a comment.
Hi Andrey thanks for responding.
Basically what I have is a docker compose file that brings up a database and python docker container. The python docker container houses the django app. The python interpreter is set up to use the python interpreter within the python container.
What I was hoping to have was while in run or debug mode the terminal would be attached to the command line in the container that python is running under.
The docker compose file contains the database credentials and creates environment variables from them.
I may be thinking this the wrong way round but the reason it would be useful would be to run migrations on the database. This would provide me with the ability to use the same interaction approach and to always interact within the container. My other aim was to make it easier for anyone else to get started with a developer environment
Hey Andrey thanks for the response. I wasn’t sure if the terminal window in pycharm could default to being an exec’d /bin/sh in the running main container. Appreciate running docker to bring up another instance is possible. Will also take a look at the services pane. Did t realise that was an option as well.
Cheers again