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?
1 Answer
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.
3 Comments
Sam R.
Installed
sshd and run the services via supervisord and now I'm able to connect to interpreter. Thanks James.Elad92
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.
James Mills
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).
runcuz I already have run it?