pycharm无法完成Docker的远程解释器设置 [英] pycharm can't complete remote interpreter setup for Docker

查看:523
本文介绍了pycharm无法完成Docker的远程解释器设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Docker的新手。我正在使用Docker& docker-compose,完成了烧瓶教程。基本的docker映像是python 2.7 slim。
它在Linux上运行。 docker 1.11.2
应用程序正常运行。
我想让pycharm pro连接到远程解释器,这是我以前从未做过的事情。

I'm new to Docker. I'm using Docker & docker-compose, going through a flask tutorial. The base docker image is python 2.7 slim. It's running on Linux. docker 1.11.2 The application is working fine. I want to get pycharm pro connecting to the remote interpreter, something I have never done before.

我按照docker-compose的说明进行操作。最初它失败了,因为它无法连接到端口2376。我将此端口添加到docker-compose.yml,错误消失了。
但是,现在尝试保存配置时会出现获取远程解释器版本对话框,此操作会暂停/挂起。这永远不会完成。另外,我无法退出pycharm。这在Pycharm 2016.2和2016.3 EAP(第2版)中发生。

I followed the instructions for docker-compose. Initially it was failing because it could not connect to port 2376. I added this port to docker-compose.yml and the error went away. However, trying to save the configuration now stalls/hangs with a dialog 'Getting Remote Interpreter Version'. This never completes. Also, I can't quit pycharm. This happens in Pycharm 2016.2 and 2016.3 EAP (2nd).

帮助提示将帮助程序复制到服务器需要SFTP支持。
这是否意味着我需要做点什么?

The help say "SFTP support is required for copying helpers to the server". Does this mean I need to do something?

推荐答案

我没有使用docker-machine
问题是无法建立对Docker API的TCP访问默认情况下在Ubuntu 16.04下。

I'm not using docker-machine The problem was that TCP access to the docker API is not established by default under ubuntu 16.04.

有人建议启用TCP / IP访问。

There are suggestions to enable TCP/IP access.

但是,JetBrains给了我最简单的解决方案:

However, JetBrains gave me the simplest solution:


如果您使用的是Linux,则很有可能Docker已将
安装为其默认设置,并且Docker有望通过UNIX使用
域文件套接字/var/run/docker.sock。并且您应该在API URL字段中指定
unix:///var/run/docker.sock。请评论
是否有帮助!

If you are using Linux it is most likely that Docker installed with its default setup and Docker is expecting to be used through UNIX domain file socket /var/run/docker.sock. And you should specify unix:///var/run/docker.sock in the API URL field. Please comment whether it helps!

此建议适用于我的Ubuntu 16.04发行版。

This suggestion worked with my Ubuntu 16.04 -derived distribution.

这会进入Build,Execution,Deployment下PyCharm首选项的Docker条目。

This goes into the Docker entry in PyCharm preferences under Build, Execution, Deployment.

您也可以在设置远程服务器时进行编辑解释器,但只能通过创建新的Docker条目来实现。

You can also edit this while setting up a remote interpreter, but only by making a new Docker entry.

TCP / IP方法

如果您想访问TCP / IP,则此方法有效,但这存在安全风险。套接字方法更好,这可能就是为什么它是默认方法。

This method works if you want TCP/IP access, but this is a security risk. The socket approach is better, which is probably why it is the default.

https://coreos.com/os/docs/latest/customizing-docker.html


自定义docker

Customizing docker

可以通过使用默认CoreOS设置覆盖
随附的单元来自定义Docker systemd单元。这样做的常见用例在下面介绍。

The Docker systemd unit can be customized by overriding the unit that ships with the default CoreOS settings. Common use-cases for doing this are covered below.

在新套接字上启用远程API

Enable the remote API on a new socket

创建一个名为/etc/systemd/system/docker-tcp.socket的文件,以使
Docker在端口2375上的TCP套接字上可用。

Create a file called /etc/systemd/system/docker-tcp.socket to make Docker available on a TCP socket on port 2375.

[Unit]
Description=Docker Socket for the API

[Socket]
ListenStream=2375
BindIPv6Only=both
Service=docker.service

[Install]
WantedBy=sockets.target

然后启用此新套接字:

systemctl enable docker-tcp.socket
systemctl stop docker
systemctl start docker-tcp.socket
systemctl start docker

测试工作:

docker -H tcp://127.0.0.1:2375 ps


我曾经想搜索ubuntu 16.04,但遇到了更简单的解决方案,但没有进行测试。

Once I thought to search for ubuntu 16.04 I came across simpler solutions, but I did not test them.

例如:

https://www.ivankrizsan.se/2016/05/18/enabling-docker-remote-api -on-ubuntu-16-04 /


编辑文件/lib/systemd/system/docker.service

Edit the file /lib/systemd/system/docker.service

修改以ExecStart开头的行,如下所示:

Modify the line that starts with ExecStart to look like this:

ExecStart=/usr/bin/docker daemon -H fd:// -H tcp://0.0.0.0:2375

我添加的是 -H tcp://0.0.0.0:2375部分。保存
修改后的文件。重新启动Docker服务:

Where my addition is the "-H tcp://0.0.0.0:2375" part. Save the modified file. Restart the Docker service:

sudo service docker restart

测试Docker API是否确实可访问:

Test that the Docker API is indeed accessible:

curl http://localhost:2375/version


这篇关于pycharm无法完成Docker的远程解释器设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆