docker-apt-get 报错 E: Unable to locate package

遇见的问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
root@ubuntu-server:~/pythonProject/flaskDockerSample# docker build . -t myflasksample
[+] Building 974.1s (7/10) docker:default
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 292B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:latest 817.0s
=> [1/6] FROM docker.io/library/ubuntu:latest@sha256:e6173d4dc55e76b87c4af8db8821b1feae4146dd47341e4d431118c7dd 7.3s
=> => resolve docker.io/library/ubuntu:latest@sha256:e6173d4dc55e76b87c4af8db8821b1feae4146dd47341e4d431118c7dd 0.0s
=> => sha256:e6173d4dc55e76b87c4af8db8821b1feae4146dd47341e4d431118c7dd060a74 1.13kB / 1.13kB 0.0s
=> => sha256:cb2af41f42b9c9bc9bcdc7cf1735e3c4b3d95b2137be86fd940373471a34c8b0 424B / 424B 0.0s
=> => sha256:e34e831650c1bb0be9b6f61c6755749cb8ea2053ba91c6cda27fded9e089811f 2.30kB / 2.30kB 0.0s
=> => sha256:29202e855b2021a2d7f92800619ed5f5e8ac402e267cfbb3d29a791feb13c1ee 29.55MB / 29.55MB 4.5s
=> => extracting sha256:29202e855b2021a2d7f92800619ed5f5e8ac402e267cfbb3d29a791feb13c1ee 2.4s
=> [internal] load build context 0.0s
=> => transferring context: 330B 0.0s
=> [2/6] RUN apt-get update 148.9s
=> ERROR [3/6] RUN apt-get install -y python3.7 python3-pip 0.6s
------
> [3/6] RUN apt-get install -y python3.7 python3-pip:
0.487 Reading package lists...
0.514 Building dependency tree...
0.515 Reading state information...
0.517 E: Unable to locate package python3.7
0.517 E: Couldn't find any package by glob 'python3.7'
0.517 E: Couldn't find any package by regex 'python3.7'
0.517 E: Unable to locate package python3-pip
------
Dockerfile:5
--------------------
3 |
4 | RUN apt-get update
5 | >>> RUN apt-get install -y python3.7 python3-pip
6 |
7 | COPY requirements.txt .
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get install -y python3.7 python3-pip" did not complete successfully: exit code: 100

解决办法 :

  • 换了镜像源 /etc/docker/daemon.json
  • 把 dockerfile 中的 apt-get update 换成 apt update 莫名发现这个很好用

更新: 2024-01-25 23:33:30
原文: https://www.yuque.com/zacharyblock/cx2om6/wraymddq9z9nodf4