I'm new to Docker. I'm using Docker & docker-compose, going through a flask tutorial. The base docker image is python 2.7 slim. It's running on Linux. docker 1.11.2 The application is working fine. I want to get pycharm pro connecting to the remote interpreter, something I have never done before.
I followed the instructions for docker-compose. Initially it was failing because it could not connect to port 2376. I added this port to docker-compose.yml and the error went away. However, trying to save the configuration now stalls/hangs with a dialog 'Getting Remote Interpreter Version'. This never completes. Also, I can't quit pycharm. This happens in Pycharm 2016.2 and 2016.3 EAP (2nd).
The help say "SFTP support is required for copying helpers to the server". Does this mean I need to do something?
I - docker-compose up
I think PyCharm will run
docker-compose up
, have you try to run this command first in your terminal (from where yourdocker-compose.yml
is) ?Maybe if some errors occur, you will get more info in your terminal.
II - pycharm docker configuration
Otherwise it could be due to your docker machine configuration in PyCharm.
What I do to configure my machine and to be sure this one is correctly configured:
1 - run
docker-machine ls
in your shell2 - copy paste the url without
tcp://
3 - go to pycharm preferences ->
Build, Execution, Deployement
->Docker
->+
to create a new server, fill the servername
field4 - paste previously copied url keeping
https://
5 - fill the path of your machine certificates folder
6 - tick
Import credentials from Docker Machine
7 - click
Detect
-> your machine should appear in the selection list8 - save this server
9 - select this server when configuring your remote interpreter, from PyCharm Preferences ->
Project
->Project Interpreter
->wheel
->add remote
->Docker
orDocker Compose
10 - you should be able to select a service name
11 - save your new interpreter
11 - try run your test twice, sometimes it could take time to initialize
I'm not using docker-machine The problem was that TCP access to the docker API is not established by default under ubuntu 16.04.
There are suggestions to enable TCP/IP access.
However, JetBrains gave me the simplest solution:
This suggestion worked with my Ubuntu 16.04 -derived distribution.
This goes into the Docker entry in PyCharm preferences under Build, Execution, Deployment.
You can also edit this while setting up a remote interpreter, but only by making a new Docker entry.
TCP/IP Method
This method works if you want TCP/IP access, but this is a security risk. The socket approach is better, which is probably why it is the default.
https://coreos.com/os/docs/latest/customizing-docker.html
Once I thought to search for ubuntu 16.04 I came across simpler solutions, but I did not test them.
For instance:
https://www.ivankrizsan.se/2016/05/18/enabling-docker-remote-api-on-ubuntu-16-04/