Pycharm cannot complete remote interpreter setup for Docker

I am new to Docker. I use Docker and docker-compose, going through a jar tutorial. Image of a basic docker - python 2.7 slim. It works on Linux. docker 1.11.2 The application is working fine. I want pycharm pro to connect to a remote interpreter, which I have never done before.

I followed the docker assembly instructions. It initially failed because it could not connect to port 2376. I added this port to the docker-compose.yml file and the error went away. However, the attempt to save the configuration now closes / freezes with the dialog "Get remote version of the interpreter". It never ends. In addition, I can’t give up picarch. This happens in Pycharm 2016.2 and 2016.3 EAP (2nd).

Help says that copying helpers to the server requires SFTP support. Does this mean that I need to do something?

+8
python docker pycharm
source share
2 answers

I do not use a docker machine. The problem was that TCP access to the docker API was not installed by default in ubuntu 16.04.

There are suggestions for enabling TCP / IP access.

However, JetBrains gave me the simplest solution:

If you use Linux, most likely Docker is installed with its default setting and Docker is expected to be used via UNIX domain socket /var/run/docker.sock. And you should specify unix: ///var/run/docker.sock in the API URL field. Please comment if this helps!

This suggestion worked with my Ubuntu 16.04 distribution.

This is included in the Docker entry in the PyCharm settings in the Build, Execution, Deployment section.

You can also edit this when setting up the remote interpreter, but only by creating a new Docker entry.

TCP / IP Method

This method works if you want access to TCP / IP, but it is a security risk. The socket approach is better, which is probably why it is by default.

https://coreos.com/os/docs/latest/customizing-docker.html

Docker setup

The Docker systemd module can be configured by overriding the device that comes with the default CoreOS settings. Common use cases are described below.

Include remote API in new socket

Create a file called / etc / systemd / system / docker -tcp.socket to make Docker available on the TCP socket on port 2375.

[Unit] Description=Docker Socket for the API [Socket] ListenStream=2375 BindIPv6Only=both Service=docker.service [Install] WantedBy=sockets.target 

Then enable this new socket:

 systemctl enable docker-tcp.socket systemctl stop docker systemctl start docker-tcp.socket systemctl start docker 

Check that his work:

 docker -H tcp://127.0.0.1:2375 ps 

As soon as I decided to find ubuntu 16.04, I came across simpler solutions, but I did not test them.

For example:

https://www.ivankrizsan.se/2016/05/18/enabling-docker-remote-api-on-ubuntu-16-04/

Edit the file /lib/systemd/system/docker.service

Change the line that starts with ExecStart to look like this:

 ExecStart=/usr/bin/docker daemon -H fd:// -H tcp://0.0.0.0:2375 

Where my addition is part of "-H tcp: //0.0.0.0: 2375". Save the modified file. Restart the Docker service:

 sudo service docker restart 

Check if the Docker API is really available:

 curl http://localhost:2375/version 
+7
source share

I'm docker compose

I think PyCharm will work docker-compose up , do you try to run this command first in your terminal (where is your docker-compose.yml )?

Perhaps if some errors occur, you will get more information in your terminal.

II - picarm docker configuration

Otherwise, this may be due to the configuration of your docker machine in PyCharm.

What am I doing to set up my machine and make sure it is configured correctly:

1 - run docker-machine ls in your shell

enter image description here

2 - copy the url without tcp://

3 - go to the settings pycharm β†’ Build, Execution, Deployement β†’ Docker β†’ + , to create a new server, fill in the server name field

enter image description here

4 - copy the previously copied https:// URL

5 - fill in the path to the folder with the certificates of your computer

6 - tick Import credentials from Docker Machine

7 - click Detect -> your computer should appear in the selection list

8 - save this server

9 - select this server when setting up your remote interpreter, from the PyCharm β†’ Project β†’ Project Interpreter β†’ wheel β†’ add remote β†’ Docker or Docker Compose settings

enter image description here

10 - you should be able to choose a service name

11 - save the new interpreter

11 - try to run the test twice, sometimes it may take time to initialize

+2
source share

All Articles