Pycharm - Docker Image on Powerful Cloud Host as a Remote Interpreter? - python

I want to use a Python Docker image running on a powerful remote machine (cloud or local network - but different from the one I sit in front of and installed PyCharm on) as PyCharm Python remote interpreter.
How do I set up the PyCharm access?
Do I need to run an ssh server on the docker image and treat it as a classic ssh remote interpreter while setting up port mapping on the cloud host machine?
The tutorials (e.g. https://blog.jetbrains.com/pycharm/2017/03/docker-compose-getting-flask-up-and-running/) apparently only apply to Docker and the Docker image running locally on the same machine as PyCharm, "localhost" or "127.0.0.1". I would like "some_machine_with_many_gpus.cloudapp.net:port" or similar. Is this possible?

Related

Setting local PyCharm remote interpreter in docker container on remote server

I have:
local PyCharm
remote server with docker container
I want run in my local PyCharm code (code on remote server) in remote docker container Python interpreter, for debug.
How to set it up?
I also found articles on the Internet, with the following description that I did not need:
local PyCharm -> ssh server interpreter
local PyCharm -> local docker
While it's not impossible to connect pycharm debugger with your remote docker container, it's much easier to use terminal interactive debugger - pdb. There are a lot of pdb flavours, if you don't like plain console
webpdb graphical debugger in a browser
pudb ncurses version, has some extra features like always listing your location in code and local variables.
I highly recommend checking them out. I use pdb on daily basis to debug python code in local docker container that has a complex run script.

Docker image producing different results with Python script between different host OS

I have been having trouble executing my python script in a remote server. However, when I build the docker image in my local machine (macOS Mojave), the docker image executes my script fine. The same docker image built in the remote server has issues with running the python script in the docker image. I was under the impression that the docker image would produce the same results regardless of its host OS. Correct if I'm wrong and what I can do to produce the same results in the remote server VM. What exactly is the underlying problem causing this issue? Should I request a new remote VM with certain specifications?

How to access a server(which is running in a docker container) from other machine?

I'm new to docker. I have deployed a python server in a docker container. And I'm able to access using my python application from my machine using virtual machine IP(192.168.99.100).
Ex: http://192.168.99.100:5000
How do I access my the application from the other machine which is in the same network?
I tried giving my machine IP but didn't work.
I run the application using "docker run -p 5000:80 myPythonApp"
An easy way out would be to forward port from your host machine to the virtual machine.
Solution may differ w.r.t the VM providers & Host OS that you use. Like for vagrant you can do something as below -
https://www.vagrantup.com/docs/networking/forwarded_ports.html

Pycharm Remote interpreter on Docker remote: [Errno 2] No such file or directory

As specified in the title I am trying to use Pycharm Professional (2018.2) with a python remote interpreter in a Docker machine hosted on a remote server in my LAN. I created a very simple example by following the help 'https://www.jetbrains.com/help/pycharm/using-docker-as-a-remote-interpreter.html'.
Pycharm 2018.2 is installed on a LAN pc (192.168.1.10) on a debian distro;
Docker is installed on a LAN debian server (192.168.1.22)
I was able to configure Docker as a remote interpreter, to connect with the Docker service through the Pycharm tool but when I try to run (or debug) the main.py in the Docker container I always get this:
37073edcd9d2:python -u /opt/project/main.py (null): can't open file '/opt/project/main.py': [Errno 2] No such file or directory
Process finished with exit code 2
The execution is certainly done in the remote Docker container but it seems that the file to be executed is not found. I manually attached the local volume as described on various blogs with all possible variations but I always get the same error.
These are some specifications of my configuration:
docker tool setting
project interpreter setting
Run/Debug Configuration
docker container setting with volume mapping into Run/Debug Configuration
Is missing something?
Tanks. Any help is appreciated!
The problem lies in the Pycharm 'limit' of managing a docker machine on a remote host 'under the hood'. When inserting the volume mapping in the run / debug configuration, it is interpreted as a local path and therefore, in this case, a path that must be present on the remote server. So, for now, the only option is to mount the local path (the folder where the project is located) on the remote host of the Docker service by first sharing it through an SSHFS or NFS service.
So ... (1) I shared the Pycharm project folder (local machine ip 192.168.1.10) using NFS; (2) I mounted the shared folder on the server host (on server ip 192.168.1.22; mount -t nfs 192.168.1.10:/home/user/PythonProjects /home/ext-user/mnt/projects) then (3) in the run / debug configuration of Pycharm I mapped the volumes with the path mounted on the remote server ... Run ... the program now runs without any errors. [Run result]
These are some specifications of my new configuration:
Run/Debug Configuration
docker container setting with volume mapping into Run/Debug Configuration
I hope the solution can be useful to other people. I also hope that there are better solutions than mine :-)

docker orchestration - connect to remote interpreter using pycharm

i'm trying to connect pycharm to docker remote interpreter, but the container is part of a cluster (specifically using AWS ECS cluster)
i can not access the container directly i have to go through the bastion machine (the instance that is running the container do not have public IP)
i.e to access the container i need to access it via bastion machine
i had an idea of using ssh tunneling but i could not figure out how to do so using pycharm docker utility
is there any solution that pycharm suggests for that?

Categories