How to use Docker with PyCharm

What you need is:

  1. Docker -
  2. docker-compose -
  3. PyCharm ;-)

I use PyCharm in 2017.12 version but even with previous ones this tutorial
should work correctly.

First you need to configure Docker. Go to File -> Settings and find Docker
section (you can use search bar).

PyCharm - Docker configuration

Just add a new Docker, fill the API URL and Docker Compose executable inputs.
When everything is added correctly you should see a "Connection successful" message.

PyCharm - Docker - successful connection

Now you need to configure Docker all your projects. Once again go to the
settings, find project configuration and choose "Project Interpreter" section.

PyCharm - project interpreter

Click settings icon and choose "Add Remote".

PyCharm - add remote interpreter

Configure project:

  • Server: choose the correct Docker configuration
  • Configuration file(s): Add a paths to your project docker-compose.yml files
  • Service: Choose Docker service/container which should be used

Click OK.

PyCharm - Docker remote interpreter

Now you need to wait some time because PyCharm needs to build own Docker container
and scan everything. After that operation PyCharm should be able see every package installed in the container and you should be able to use for example "Go To" command or Docker tools from Pycharm.

PyCharm - Go To command