Remote Development with a Docker
I have come so far to get to this point, but cannot seem to get it to work. Can anyone tell me what I might be doing wrong? Here are my steps.
I selected Remote Development, new SSH connection.
Input username and host, click "check connection" and It comes back "Successfully", then select "Start IDE and Connect" (the IDE is already installed on the host), and I input my project folder.
The Remote Development window comes up.
I have a python file called "whatev.py", it's very simple, it just prints some stuff to the screen. I'm trying to get it to run inside a docker image that is on the remote host, and so I go to "settings"->"Build, Execution, Deployment:"->"Docker". I select “Detect executable paths automatically” and select “Unix socket:”. I see the “Connection successful” near the bottom and click “OK”.
Then I go to "Settings"->"Project"->"Python Interpreter" and follow the 3 steps:
- "Create a new Docker target", I select "Pull or use existing" and type the image of my docker that exists on the host
- I hit next and it says "Pulling Docker image", it pulls and launches a container, then it tries to find python3, and fails because this docker has a custom python, I'll call it custom_python
- I'm still allowed to go to "next", and so I do. Now, in "Project directory and language runtime configuration" I'm able to select my custom python as the Interpreter, I do, and I press "create".
All seems to be well, I'm back on the "Python Interpreter" page, I see my selected python executable in the "Python Interpreter" box, so I press "ok".
I see at the bottom left of PyCharm that it is updating to the python interpreter that I selected. I can also hover over the bottom right of PyCharm and it gives me all the info I just set up: the name of my interpreter and the name of my docker image.
Now I have whatev.py open and I press the play button on the top (hovering over it says "Run 'whatev' Shift+F10"). I press it, it immediately greys out and nothing happens. I then press the debug button. I wait for a while and then get an error saying "Error running 'whatev': com.intellij.docker.agent.ApiTaskException: Can't retrieve image ID from build stream".
Investigating a little, I go to “Services” on the bottom left and can see all the images and containers. I can even create one from here, go into it with a terminal and type in “custom_python” and I'm dropped into a python interpreter as expected. But still my execution of my code is a no go.
What can I do next?
请先登录再写评论。
Unfortunately, the problem is not reproducible for me with latest PyCharm and docker engine.
Please create an issue in the PyCharm branch of the YouTrack (https://youtrack.jetbrains.com/issues/PY) so we can investigate this issue properly, attach remote session logs (start remote development and do Help | Collect Host and Client Logs) and Dockerfile to the thread.
Also, is this custom Python executable somehow modified? If yes, please explain how to replicate the same executable.
Thanks for taking a look Daniil. I will grab the logs and attach, however I am not using a Dockerfile. I assumed that since I selected “Pull or use existing” and not “Build” on the “Add Interpreter → On Docker” menu, I would not need one. Do I still need to have a Dockerfile even though I'm not building an image?