gpt4 book ai didi

python - 软件包未使用pip安装在Docker容器内

转载 作者:行者123 更新时间:2023-12-02 19:50:07 28 4
gpt4 key购买 nike

我对docker-compose面临的一个奇怪问题感到困惑。对于Requirements.txt文件中的某些软件包,点安装失败。

docker 版本

Client:
Version: 18.09.9
API version: 1.39
Go version: go1.13.4
Git commit: 1752eb3
Built: Sat Nov 16 01:05:26 2019
OS/Arch: linux/amd64
Experimental: false

Server:
Engine:
Version: 18.09.9
API version: 1.39 (minimum version 1.12)
Go version: go1.13.4
Git commit: 9552f2b
Built: Sat Nov 16 01:07:48 2019
OS/Arch: linux/amd64
Experimental: false

我的 docker-compose.yml文件是:
version: "3.7"

services:

flask:
build: ./flask
container_name: flask
restart: always
environment:
- APP_NAME=MyFlaskApp
expose:
- 8080

nginx:
build: ./nginx
container_name: nginx
restart: always
ports:
- "80:80"

./flask目录中 Dockerfile的内容为:
# Use the Python3.7.5 image
FROM python:3.7.5

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
ADD . /app

# Install the dependencies
RUN pip3 install -r requirements.txt

# run the command to start uWSGI
CMD ["uwsgi", "app.ini"]

我的 requirements.txt文件是(前几行):
appdirs==1.4.3
apturl==0.5.2
asn1crypto==0.24.0
bcrypt==3.1.6
blinker==1.4

但是,当我运行 docker-compose up命令时,它无法在 requirements.txt文件中安装第二个软件包。
Building flask
Step 1/6 : FROM python:3.7.5
---> fbf9f709ca9f
Step 2/6 : WORKDIR /app
---> Using cache
---> 39ab3ee34991
Step 3/6 : ADD . /app
---> Using cache
---> 8968809ff844
Step 4/6 : RUN python3 -m pip install --upgrade pip
---> Using cache
---> 15f717de5181
Step 5/6 : RUN pip3 install -r requirements.txt
---> Running in 7068f09498dc
Collecting appdirs==1.4.3
Downloading appdirs-1.4.3-py2.py3-none-any.whl (12 kB)
ERROR: Could not find a version that satisfies the requirement apturl==0.5.2 (from -r requirements.txt (line 2)) (from versions: none)
ERROR: No matching distribution found for apturl==0.5.2 (from -r requirements.txt (line 2))
ERROR: Service 'flask' failed to build: The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1

我尝试了很多可能的选择,但没有用。一些例子是:
  • 在容器内运行pip升级。
  • 根据线程here更新docker中的DNS。
  • 最佳答案

    正如@ WilliamD.Irons已经指出的here apturl是一个软件包,可以使用:

    RUN apt install apturl
    RUN pip3 install -r requirements.txt

    并从您的 apturl中删除 requirements.txt

    关于python - 软件包未使用pip安装在Docker容器内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61191757/

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