Using Docker Remote Interpreter in PyCharm on Linux


Note: This functionality is only available for Professional version of PyCharm

Step 1: Export Docker Daemon via TCP

# stop docker service
sudo service docker stop

# export daemon
sudo dockerd -H unix:///var/run/docker.sock -H tcp://

The Docker daemon can listen for Docker Engine API requests via three different types of Socket: unix, tcp, and fd.

By default, a unix domain socket (or IPC socket) is created at /var/run/docker.sock, requiring either root permission, or docker group membership.

If you need to access the Docker daemon remotely, you need to enable the tcp Socket. Beware that the default setup provides un-encrypted and un-authenticated direct access to the Docker daemon - and should be secured either using the built in HTTPS encrypted socket, or by putting a secure web proxy in front of it. You can listen on port 2375 on all network interfaces with -H tcp://, or on a particular network interface using its IP address: -H tcp:// It is conventional to use port 2375 for un-encrypted, and port 2376 for encrypted communication with the daemon.

Step 2: Configure PyCharm

In Settings - Build, Execution, Deployment - Docker, click the plus button and select Unix socket as connection method.

In Settings - Project Settings - Python Interpreter, select the docker server and docker image.

That’s all, now you can run your code from python environment inside a docker image.

(Optional)Step 3: Change Default Runtime of Docker

If you are using nvidia-docker, an error might prompt:

no nvidia drivers found.

In this case, try the following solution:

In /etc/docker/daemon.json, change this file as follows:

    "default-runtime": "nvidia",
    "runtimes": {
      "nvidia": {
        "path": "/usr/bin/nvidia-container-runtime",
        "runtimeArgs": []