PyCharm 2021.2 Help

Docker Compose

Prerequisites

Make sure that the following prerequisites are met:

  • Docker Compose is installed, as described on the page Docker Compose.

  • You have a stable Internet connection.

    Ensure that you have a stable Internet connection, so that PyCharm can download and run busybox:latest. Once you have successfully configured Docker, you can go offline.

  • Before you start working with Docker Compose, make sure that the 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 IDE settings Ctrl+Alt+S as described in Manage plugins.

    In the Settings/Preferences dialog Ctrl+Alt+S, select Build, Execution, Deployment | Docker, and select Docker for <your operating system> under Connect to Docker daemon with. For example, if you're on macOS, select Docker for Mac. See more detail in Docker settings.

Note that PyCharm supports docker-compose configuration versions up to 3.x.

Important note

A chosen service declared within a Docker Compose configuration file is supported as a Python interpreter. Python run configurations based on this interpreter operate like docker-compose up command with the addition that it maps project sources into the chosen service container.

The feature works for Linux with the local installations of Docker and macOS, it won't be shown in PyCharm running on Windows platform. On macOS, Docker Compose configuration file must be situated within the default shared folder /Users/.

Working with Docker Compose

In the Settings/Preferences dialog Ctrl+Alt+S box, expand the node Build, Execution, Deployment, and in the Docker | Tools page, add the required Docker settings and then specify the Docker Compose executable.

As a result, the Docker Compose option appears in the Configure Remote Python Interpreter dialog.

See the Configure an interpreter using Docker Compose tutorial for detailed information on working with Docker Compose in PyCharm.

Last modified: 05 August 2021