首页 > 解决方案 > Dockerfile 中的 apt-get update 失败

问题描述

当我尝试构建一个简单的 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”没有发布文件。

  2. 我从我的系统中完全删除并重新安装了 docker,包括所有容器和存储库,然后重新启动,并得到相同的错误

我之前构建了多个 docker 镜像,一切正常。而现在我总是莫名其妙地得到这个错误。

标签: linuxdockerubuntuapt-get

解决方案


推荐阅读