PyCharm 5.0 Help

Configuring Remote Interpreters via Docker

You can add Docker support to PyCharm by installing the Docker integration plugin.

Prerequisites

Make sure that the following prerequisites are met:

  • Docker is installed, as described on the page Docker Toolbox (MacOS and Windows).
    For Linux, one should follow the instructions on the page On Linux.
  • Before you start working with Docker, make sure that Docker for Python plugin is enabled. The plugin is bundled with PyCharm and activated by default. If it is not, enable the plugin as described in the section Enabling and Disabling Plugins.

Configuring remote interpreter using Docker

To set up a Python interpreter inside a Docker container for your project, follow these steps:

  1. In the Project Interpreter page of the Settings/Preferences dialog box, click cogwheel_framed, and then choose Add Remote.
  2. From the Configure Remote Python Interpreter dialog box that opens, choose the option Docker:
    py_choose_docker
  3. Specify the path to the Docker machine executable, machine name, and image name. The remote API URL, certificates folder and Python interpreter path are specified based on the Docker installation.
    py_choose_docker1

The configured remote interpreter is set as the project interpreter. Now you can Run, Debug and Profile your application using Python inside a Docker container.

Note that if the project interpreter is created via Docker, the packages toolbar is not available.

The buttons on this toolbar are disabled for the Docker interpreters:

py_packages_toolbar_for_docker

All the packages should be already installed in the Docker image. If some packages are missing, then you will have to create a new Docker image, as described on the page Quickstart Guide: Compose and Django.

Limitation

As of this writing, on Windows and MacOS platforms running, debugging and profiling applications is only possible for the projects residing in the user home directory. If necessary, configure other directories in the VirtualBox settings.

Docker Machine on Linux does not share user home folder, and any other folders as well. Thus, for running, debugging and profiling applications, the user should add shared folders with the project sources to the VirtualBox Docker virtual machine manually. These shared folders on VM should be mapped one to one to the folders on the host Linux machine, i.e. (host) /home/user <=> /home/user (VM) or (host) /home/my/project <=> /home/my/project (VM)

See Also

Last modified: 10 December 2015