Dockerfile 中的 apt-get update 失败

3
当我尝试构建一个简单的Docker镜像时:
在Dockerfile中:
FROM ubuntu:18.04

RUN apt-get update

输出结果为:
$ sudo docker build --no-cache -t testbuild .
Sending build context to Docker daemon  3.471MB
Step 1/2 : FROM ubuntu:18.04
 ---> c090eaba6b94
Step 2/2 : RUN apt-get update
 ---> Running in 53d64603442f
Ign:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Ign:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
Ign:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Err:4 http://security.ubuntu.com/ubuntu bionic-security Release
  404  Not Found [IP: 91.189.88.142 80]
Ign:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Err:6 http://archive.ubuntu.com/ubuntu bionic Release
  404  Not Found [IP: 91.189.88.152 80]
Err:7 http://archive.ubuntu.com/ubuntu bionic-updates Release
  404  Not Found [IP: 91.189.88.152 80]
Err:8 http://archive.ubuntu.com/ubuntu bionic-backports Release
  404  Not Found [IP: 91.189.88.152 80]
Reading package lists...
E: The repository 'http://security.ubuntu.com/ubuntu bionic-security Release' does not have a Release file.
E: The repository 'http://archive.ubuntu.com/ubuntu bionic Release' does not have a Release file.
E: The repository 'http://archive.ubuntu.com/ubuntu bionic-updates Release' does not have a Release file.
E: The repository 'http://archive.ubuntu.com/ubuntu bionic-backports Release' does not have a Release file.
The command '/bin/sh -c apt-get update' returned a non-zero code: 100

我尝试过:
  1. 使用不同类型的Ubuntu镜像构建,例如ubuntu:16.04、18.04、20.04等,并且遇到了相似的错误“...Release”没有Release文件。

  2. 我完全卸载并重新安装了我的系统中的docker,包括所有容器和存储库,并重新启动,但仍然出现相同的错误。

之前我构建了多个docker镜像,一切都很正常。现在我总是突然出现这个错误。


1
嗨 @GAD3R - 是的,它是docker-ce - undefined
1
据我所知和我所查到的(尽管我是使用大学网络),并没有这样的情况。 - undefined
1
我注意到的一件事是,docker ubuntu date 命令给出的时间是UTC时间,而我的本地时区是EST(UTC-5)。我尝试了各种方法来更改这个问题,但是同样的错误仍然存在。例如,我在这里找到了类似的问题 - undefined
apt update之前尝试添加RUN echo "Your-TimeZone" > /etc/timezoneRUN dpkg-reconfigure -f noninteractive tzdata - undefined
1
为了同步时钟,我做了以下操作:1. 构建一个只有一行的容器 FROM ubuntu(即没有其他命令);2. 运行容器,并从本地机器复制时间 - docker run -it --rm -v /etc/localtime:/etc/localtime testbuilt /bin/bash;3. 通过运行 date 命令来检查时间(现在时间已经修正);4. 尝试在容器内运行 apt-get update 命令 - 但是仍然出现相同的错误(does not have a Release file),所以我知道问题不是由于时间差异引起的。 - undefined
显示剩余4条评论
1个回答

0
我知道这是一个老问题,但我今天也遇到了这个问题。对我来说,“解决方案”是使用一个更新的镜像...
我之前使用的是`ubuntu:21.04`,而且出现了这个错误,但是改用`ubuntu:22.04`,没有做其他任何更改,就没有出现这个错误。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接