So I have set up a docker on my laptop. I'm using Boot2Docker so I have one level of indirection to access the docker. In PyCharm, I can set a remote python interpreter via SSH but I'm not sure how to do it for dockers that can only be accessed via Boot2Docker?
Asked
Active
Viewed 2,242 times
1
-
A remote python interpreter a running container? – James Mills Jun 16 '15 at 21:36
-
1So your container will *have* to be running SSH and exposed to the boot2docker/virtualbox host and you connect to the boot2docker/virtualbox host's exposed ssh port via PyCharm to connect up to your remote Python interpreter. – James Mills Jun 16 '15 at 21:40
-
Thank you. I'll give it a research on how to forward the SSH. – Sam R. Jun 16 '15 at 21:43
-
@JamesMills, thank you so much. Why don't you post it as answer? And what if I run my container as daemon with a webserver running? Can I attach to a running container instead of `run` cuz I already have run it? – Sam R. Jun 16 '15 at 21:47
-
@JamesMills got two downvotes and a close vote with no comment as to why they think so. Weirdos are everywhere. – Sam R. Jun 16 '15 at 22:00
-
I'm upvoting this because this was a good question. 3 people also favourited so I don't know what's going on. – SARose Dec 26 '15 at 01:49
1 Answers
3
Okay so to answer your question(s):
In PyCharm, I can set a remote python interpreter via SSH but I'm not sure how to do it for dockers that can only be accessed via Boot2Docker?
You need:
- To ensure that you have SSH running in your container
There are many base images that include SSH. See: Dockerizing an SSH Daemon
Expose the SSH service to the Boot2Docker/VirtualBox VM.
docker run -d -p 2222:22 myimage ...
Setup PyCharm to connect to your Boot2Docker/VirtualBox VM.
boot2docker ip
Attaching to a running container is easy too!
$ boot2docker ssh
$ docker exec -i -t <cid> /bin/bash
Where <cid>
is the Container ID or Name (if you used --name
.

James Mills
- 18,669
- 3
- 49
- 62
-
Installed `sshd` and run the services via `supervisord` and now I'm able to connect to interpreter. Thanks James. – Sam R. Jun 17 '15 at 20:41
-
Did you manage to debug a python class using the remote interpreter? i'm able to connect to the interpreter when running a class, however when trying to debug it fails trying to open additional ports. – Elad92 Jul 02 '15 at 16:36
-
What is the failure messages and what ports is it trying to open? (*I'm ignorant of PyCharm and I don't actually use it*). – James Mills Jul 02 '15 at 23:48