Search code examples
dockerpycharm

How to add a docker volume mount to PyCharm on a Mac - missing "Docker container settings"


Using PyCharm 2022.3.2 (Professional Edition) on Mac we've set up a docker container and can run a Python script within that container successfully from PyCharm.

We want to add a volume mount to our Run Configuration.

On another ubuntu based computer, the PyCharm Run Configuration dialogue has a section titled "Docker container settings:" where the volume mount is added. On a Mac we're setting up, this setting is not present. Two screenshots show the difference below.

Screenshot on a Mac (missing "Docker container settings"):

enter image description here

Screenshot on an Ubuntu-Linux OS (includes "Docker container settings"):

enter image description here

Can anyone see why the Mac is missing the "Docker container settings:" section in the Run Configurations dialogue?


Solution

  • Perhaps PyCharm on the Mac is not connected to the Docker daemon.

    According to the PyCharm documentation, to connect to the Docker daemon:

    1. Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Docker.
    2. Click The Add button to add a Docker configuration and specify how to connect to the Docker daemon.

    The connection settings depend on your Docker version and operating system. For more information, see Docker connection settings.

    The Connection successful message should appear at the bottom of the dialog.

    enter image description here

    1. Open the Services tool window (View | Tool Windows | Services or Alt+8), select the configured Docker connection node Docker node and click The Connect button, or select Connect from the context menu.

    enter image description here

    To edit the Docker connection settings, select the Docker node and click The Edit Configuration button on the toolbar, or select Edit Configuration from the context menu.

    You can also click the Add Service menu and select Docker Connection to add a Docker connection directly from the Services tool window. If you have Docker contexts configured, you can select Docker Connections from Docker Contexts to add the corresponding connections.

    Reference: PyCharm Documentation - Docker (archive.org)