Sam R.
Sam R.

Reputation: 16450

PyCharm add remote Python interpreter inside the Docker

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?

Upvotes: 1

Views: 2278

Answers (1)

James Mills
James Mills

Reputation: 19030

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.

Upvotes: 3

Related Questions