Pycharm Couldn't connect to console process when using remote docker interpreter

Viewed 289

I am trying to run my code within a docker container hosted on an AWS EC2 machine.

It seems that PyCharm can connect to the interpreter because it can show the list of installed packages when looking at the interpreter configuration.

However, when I try to open a Python console, or when I try to run a Python script, I have the error:

3987f6fc2476:/usr/bin/python3 /opt/.pycharm_helpers/pydev/pydevconsole.py --mode=server --port=55516
Couldn't connect to console process.
Process finished with exit code 137 (interrupted by signal 9: SIGKILL)

Happy to provide more information. What is possibly going wrong here? The error seems pretty generic.

EDIT: PyCharm can start the docker container but still the Python console won't work. On the server, docker ps returns:

ecd6a7220b55   9e1ad5b17633                                                                                                                    "/usr/bin/python3 /o…"   1 second ago   Up Less than a second     22/tcp, 0.0.0.0:50219->50219/tcp   dreamy_matsumoto
1 Answers

Turns out that the issue with that PyCharm used a random port every time it starts a Python console when connecting to remote docker container. If we could open all the inbound ports on the EC2, this feature would work. Of course there is nothing worst from a security perspective. Do NOT do this. (but if you really want to do it you'll need to setup docker through TCP)

Related