PyCharm add remote Python interpreter inside the Docker

久未见 提交于 2019-12-09 13:54:19

问题


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:


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.



来源:https://stackoverflow.com/questions/30878505/pycharm-add-remote-python-interpreter-inside-the-docker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!