我正在遵循fig guide来将docker与python应用程序一起使用,但是当docker开始执行命令时
RUN pip install -r requirements.txt
我收到以下错误消息:
Step 3 : RUN pip install -r requirements.txt
---> Running in fe0b84217ad1
Collecting blinker==1.3 (from -r requirements.txt (line 1))
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', gaierror(-2, 'Name or service not known'))': /simple/blinker/
重复几次,然后我得到另一条消息:
Could not find any downloads that satisfy the requirement blinker==1.3 (from -r requirements.txt (line 1))
No distributions at all found for blinker==1.3 (from -r requirements.txt (line 1))
因此出于某种原因,pip无法从docker容器中访问任何包。有什么我需要做的允许它上网吗?
不过,pip可以很好地安装docker容器之外的东西,甚至可以很好地安装那个确切的包(blinker==1.3
),所以这不是问题所在。这个问题也不是那个包特有的。对于任何包,任何pip install
命令都会遇到同样的问题。
有人知道这是怎么回事吗?
这就是我的解决方案:
我有同样的问题,它困扰了我一段时间,我在网上尝试了很多解决方案,但都没有成功。不过,我最后决定如下:
运行:
查找DNS服务器的地址。
通过运行以下命令查找DNS服务器的地址:
更新Docker守护进程
在
/etc/docker/daemon.json.
(如果您还没有一个)创建docker配置文件,并将以下内容添加到文件中:数组的第一项是网络的DNS服务器,第二项是google的DNS服务器,当网络的DNS不可用时作为备用。
保存文件,然后重新启动docker服务
你的问题来自Docker没有使用正确的DNS服务器。 你可以用三种不同的方法修复它:
一。将Google DNS添加到本地配置
修改/etc/resolv.conf并在末尾添加以下行
# Google IPv4 nameservers nameserver 8.8.8.8 nameserver 8.8.4.4
如果要添加其他DNS服务器,请查看here。
不过,这种变化不会是永久性的(请参见this thread)。使之永久:
$ sudo nano /etc/dhcp/dhclient.conf
取消注释并编辑带有前置域名服务器的行:prepend domain-name-servers 8.8.8.8, 8.8.4.4;
重新启动dhclient:
$ sudo dhclient
。2。修改Docker配置
作为explained in the docs:
三。运行Docker时使用参数
运行docker时,只需添加以下参数:
--dns 8.8.8.8
相关问题 更多 >
编程相关推荐