1

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?

6
  • A remote python interpreter a running container? Commented Jun 16, 2015 at 21:36
  • 1
    So 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. Commented Jun 16, 2015 at 21:40
  • Thank you. I'll give it a research on how to forward the SSH. Commented Jun 16, 2015 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? Commented Jun 16, 2015 at 21:47
  • @JamesMills got two downvotes and a close vote with no comment as to why they think so. Weirdos are everywhere. Commented Jun 16, 2015 at 22:00

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Installed sshd and run the services via supervisord and now I'm able to connect to interpreter. Thanks James.
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.
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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.