gpt4 book ai didi

python - 通过 Ubuntu 的 apt-get 在 Dockerfile 中使用 apt-get 安装 python-pip

转载 作者:行者123 更新时间:2023-12-04 18:36:26 25 4
gpt4 key购买 nike

我正在浏览以下博客文章:

https://codefresh.io/docker-tutorial/hello-whale-getting-started-docker-flask/

这是该项目的 Github 存储库(由作者提供):

https://github.com/ChloeCodesThings/chloe_flask_docker_demo

Dockerfile:

FROM ubuntu:latest
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT ["python"]
CMD ["app.py"]

将此项目克隆到运行 macOS Catalina (10.15.4) 的本地计算机后。

并运行以下命令(从 web 文件夹中):
docker build -t flask-hello:latest .

标准输出中的输出:
Sending build context to Docker daemon  36.86kB
Step 1/8 : FROM ubuntu:latest
latest: Pulling from library/ubuntu
d51af753c3d3: Pull complete
fc878cd0a91c: Pull complete
6154df8ff988: Pull complete
fee5db0ff82f: Pull complete
Digest: sha256:747d2dbbaaee995098c9792d99bd333c6783ce56150d1b11e333bbceed5c54d7
Status: Downloaded newer image for ubuntu:latest
---> 1d622ef86b13
Step 2/8 : RUN apt-get update -y
---> Running in b85d892341c1
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [3717 B]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease [106 kB]
Get:5 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [35.3 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [3190 B]
Get:7 http://archive.ubuntu.com/ubuntu focal-backports InRelease [89.2 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
Get:9 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [14.1 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [3190 B]
Get:14 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [42.7 kB]
Fetched 13.5 MB in 4s (3264 kB/s)
Reading package lists...
Removing intermediate container b85d892341c1
---> 3b5aa4c86a97
Step 3/8 : RUN apt-get install -y python-pip python-dev build-essential
---> Running in a9f9fdde1725
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package python-pip
The command '/bin/sh -c apt-get install -y python-pip python-dev build-essential' returned a non-zero code: 100

docker 版本:
Client: Docker Engine - Community
Version: 19.03.8
API version: 1.40
Go version: go1.12.17
Git commit: afacb8b
Built: Wed Mar 11 01:21:11 2020
OS/Arch: darwin/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 19.03.8
API version: 1.40 (minimum version 1.12)
Go version: go1.12.17
Git commit: afacb8b
Built: Wed Mar 11 01:29:16 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683

为什么找不到 python-pip对于 Ubuntu 使用 apt-get ?任何建议都非常感谢!

最佳答案

我怀疑 Dockerfile 中的第一行尝试使用最新的 Ubuntu 版本 20.04 ,那个没有包。

更改为版本 18.04它会起作用:

FROM ubuntu:18.04
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT ["python"]
CMD ["app.py"]

关于python - 通过 Ubuntu 的 apt-get 在 Dockerfile 中使用 apt-get 安装 python-pip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61564756/

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