PyCharm 2017.1 Help

Docker

This feature is supported in the Professional edition only.

Prerequisites

Make sure that the following prerequisites are met:

  • Docker is installed, as described on the page Docker Docs. You can install Docker on the various platforms:
    • Windows
    • macOS
    • Linux (Ubuntu, other distributions-related instructions are available as well)
  • Before you start working with Docker, make sure that the Docker integration plugin is enabled. The plugin is bundled with PyCharm and is activated by default. If the plugin is not activated, enable it on the Plugins page of the Settings / Preferences Dialog as described in Enabling and Disabling Plugins.

  • Before you start working with Docker, make sure that the Python Docker plugin is enabled. The plugin is bundled with PyCharm and is activated by default. If the plugin is not activated, enable it on the Plugins page of the Settings / Preferences Dialog as described in Enabling and Disabling Plugins.

Overview of Docker support

The Docker integration plugin adds the following to PyCharm:

Configuring PyCharm to work with Docker

  1. In the Settings / Preferences dialog, open the Docker page under Build, Execution, Deployment, and click /help/img/idea/2017.1/add.png to create a Docker configuration:
    /help/img/idea/2017.1/py_docker_settings.png
  2. In the Docker page, provide the following information:
    • Name. Here it is MyDocker.
    • API URL. Here it is http://localhost:2375.
    • Certificates folder. Here it is /Users/<user name>/.docker/machine/machines/default
  3. Apply the changes and close the Settings / Preferences dialog.

After that, you can configure a remote interpreter using Docker:

/help/img/idea/2017.1/py_choose_docker.png

Creating a Docker Deployment run/debug configuration

Having set up Docker, create the run/debug configuration. The Docker Deployment run/debug configuration can be used to download and build the Docker images, to create and start the Docker containers.

First, in the Deployment tab of the Docker Deployment run/debug configuration dialog, specify the following:

  • Name. Here it is Start Docker.
  • Server. Here Docker server is selected from the drop-down list.
  • Deployment. Here Docker Image is selected.
  • Image ID . Here it is mysite.
  • Container. Here it is Docker .
/help/img/idea/2017.1/py_docker_run_config.png

Next, in the Container tab, specify the necessary parameters.
At this point we are interested in exposing 80 port of the container to be available from our local machine, so we should configure a port binding for that:

Container port: 80, Protocol: tcp, Host IP: empty, Host port: 8080

Apply changes and close the Docker Deployment run/debug configuration dialog.

Working with Docker in PyCharm

As all the tools are installed, and the integration is configured, the recently created Start Docker Run/Debug Configuration can be launched:

/help/img/idea/2017.1/rm_docker_run_config2.png

The Docker tool window opens, updating you on the provisioning status and the current state of all your Docker containers.

/help/img/idea/2017.1/rm_docker_app_servers_tw.png

See Also

Last modified: 26 July 2017