gpt4 book ai didi

python - pip安装在docker容器中不起作用

转载 作者:行者123 更新时间:2023-12-02 18:05:40 27 4
gpt4 key购买 nike

我在flask中创建了一个小项目,我正在尝试使用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命令。

最佳答案

安装pip时,您的容器无法连接到Internet,因此您需要解决此问题。我认为从您的docker文件中删除代理应该可以解决此问题。

关于python - pip安装在docker容器中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61552339/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com