Important! This article assumes you are using the PyCharm EAP 2017.1 release or newer.

Open your Divio project with PyCharm

First, Setup the project locally with Divio. 

Then, in PyCharm, open the project in the usual way.

Set up PyCharm and Docker

  1. Open PyCharm's Settings/Preferences 
  2. Search for Docker in Build, Execution, Deployment
  3. Select Docker and press the "+" icon (this may set up Docker automatically, possibly with incorrect settings). You will need to set them to:
  • API URL (for Macintosh): unix:///var/run/docker.sock 
  • API URL (for Windows): tcp://localhost:2375  
  • Docker Compose executable: docker-compose 
  • Allow it to Import credentials from Docker Machine.

Project Setup

Now we need to associate the project with its docker-compose.yml  file.

  1. In PyCharm's Settings/Preferences dialog, search for Project Interpreter and select it.
  2. Click on the settings icon on the right and select Add Remote.
  3. Select Docker Compose. It should find your project's docker-compose.yml  file (not yet supported on Windows).
  4. For Service, select web.
  5. Hit OK. It may take a few moments to discover the correct Python interpreter and apply the settings.

Run configuration

Check your project's Run configuration. In the toolbar, you'll be able to  Edit configurations.

You should have:

  • Host: 0.0.0.0 
  • Port: 80 
  • Run browser: http://0.0.0.0:8000 

After saving, your project should now be ready to run, using Control-R or the green Run icon in its toolbar.

Note: not all of these PyCharm's features are available when using Docker - for example, debugging tools will not work.

Did this answer your question?