Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 构建docker映像时无法安装要求_Python_Docker_Fedora - Fatal编程技术网

Python 构建docker映像时无法安装要求

Python 构建docker映像时无法安装要求,python,docker,fedora,Python,Docker,Fedora,尝试在Docker中构建一个简单的Django应用程序,它在Fedora 31上运行,但在Fedora 32上无法运行 这是我的Dockerfile,非常简单: FROM python:3 WORKDIR /usr/src/app COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt COPY manage.py manage.py # More COPYs CMD [ "python" "./m

尝试在Docker中构建一个简单的Django应用程序,它在Fedora 31上运行,但在Fedora 32上无法运行

这是我的Dockerfile,非常简单:

FROM python:3
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY manage.py manage.py
# More COPYs

CMD [ "python" "./manage.py" "runserver" ]
但是,它在运行pip安装时失败:

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) 
after connection broken by 
'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f6bbfda0280>: 
Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/asgiref/

但这不起作用。有什么想法吗?

错误表明是网络(代理)问题,而不是软呢帽问题

pip
https://files.pythonhosted.org

  • 你能从主机ping这个URL吗
  • 从主机上的docker容器中
我发现在试图确定问题时,手动运行Dockerfile命令非常有用:

docker运行——交互式——tty python:3 bash
然后:

PYPI=”$(\
卷曲\
--沉默的\
--写出“{http\u code}\n”\
--输出/dev/null\
https://files.pythonhosted.org)"
如果[“200”=“${PYPI}”]
然后
回音“可访问”
其他的
回音“无法访问”
fi
如果需要单个命令:

docker运行\
--互动的\
--tty\
python:3\
卷曲\
--沉默的\
--写出“{http\u code}\n”\
--输出/dev/null\
https://files.pythonhosted.org
这将确认PyPi是否可访问。在容器中(见上文),您可以使用类似以下内容来获取有关
pip安装的更多信息:

pip3——详细安装
注意用您的一个软件包替换
flask


谢谢你的回答。我可以从我的机器上敲打它,但不能从容器内敲打。从容器内部安装pip会产生与我的原始问题相同的错误。啊哈!然后,出于某种原因,您的机器似乎禁止来自容器的出站请求。不幸的是,我无法解释为什么会这样(Fedora 32),但有可能网络安全性发生了变化,这将是您探索的下一步。我查看了firewalld日志,它显示警告:COMMAND_失败:“/usr/sbin/iptables-w10-D FORWARD-I docker0-o docker0-j DROP”失败:iptables:错误规则(该链中是否存在匹配规则?)
--dns 10.252.252.252 --dns 10.253.253.253 --dns 8.8.8.8