【发布时间】:2020-05-01 23:21:41
【问题描述】:
我在烧瓶中创建了一个小项目,我正在尝试使用 docker 部署它。为此,我创建了如下所示的 Dockerfile:
FROM python:3.6-stretch
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
# Install the dependencies
RUN pip install --user -r requirements.txt
# run the command to start uWSGI
CMD ["uwsgi", "app.ini"]
我的 requirements.txt 文件包含以下内容:
#click==7.1.1
Flask==1.1.2
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
uWSGI==2.0.18
Werkzeug==1.0.1
我尝试使用带有 --network=host 选项的 docker-build 以及使用 docker-compose 来构建我的项目,但没有成功。我收到以下错误:
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 0x7fac273160f0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/flask/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fac27316588>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/flask/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fac27316828>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/flask/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fac273166a0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/flask/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fac273168d0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/flask/
ERROR: Could not find a version that satisfies the requirement Flask==1.1.2 (from -r requirements.txt (line 2)) (from versions: none)
ERROR: No matching distribution found for Flask==1.1.2 (from -r requirements.txt (line 2))
我不知道为什么会收到此错误。有人可以帮我吗?我在 python 虚拟环境中运行 docker-compose build 命令。
【问题讨论】:
-
对于python3它被称为pip3
-
代理是干什么用的?你能从容器和主机内部连接到代理吗?
-
@AndyShinn 我一开始没有它们,但它给了我同样的错误。然后我搜索了互联网并尝试了它,并看到了使用它的建议。因此我使用了它。它仍然显示相同的错误
标签: python docker pip ubuntu-16.04