![从 maven:3.5.2-jdk-8 构建 dockerfile 时,apt-get update 无法获取 debian amd64 软件包](https://linux22.com/image/219483/%E4%BB%8E%20maven%3A3.5.2-jdk-8%20%E6%9E%84%E5%BB%BA%20dockerfile%20%E6%97%B6%EF%BC%8Capt-get%20update%20%E6%97%A0%E6%B3%95%E8%8E%B7%E5%8F%96%20debian%20amd64%20%E8%BD%AF%E4%BB%B6%E5%8C%85.png)
Dockerfile:
FROM maven:3.5.2-jdk-8
RUN apt-get update && \
apt-get install -y python-dev python-pip
RUN pip install awscli --upgrade
构建日志:
Preparing build context archive…
[==================================================>]3380/3380 files
Done
Sending build context to Docker daemon…
[==================================================>] 23.19MB
Done
Step 1/17 : FROM maven:3.5.2-jdk-8
---> d07bef19f01a
Step 2/17 : RUN apt-get update && apt-get install -y python-dev python-pip
---> Running in ebed1b8ce61e
Ign:1 http://security.debian.org stretch/updates InRelease
Ign:2 http://deb.debian.org/debian stretch InRelease
Ign:3 http://security.debian.org stretch/updates Release
Ign:4 http://deb.debian.org/debian stretch-updates InRelease
Ign:5 http://deb.debian.org/debian stretch Release
Ign:6 http://deb.debian.org/debian stretch-updates Release
Ign:7 http://deb.debian.org/debian stretch/main arm64 Packages
Ign:8 http://deb.debian.org/debian stretch/main all Packages
Ign:9 http://deb.debian.org/debian stretch-updates/main arm64 Packages
Ign:10 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:7 http://deb.debian.org/debian stretch/main arm64 Packages
Ign:8 http://deb.debian.org/debian stretch/main all Packages
Ign:11 http://security.debian.org stretch/updates/main arm64 Packages
Ign:12 http://security.debian.org stretch/updates/main all Packages
Ign:11 http://security.debian.org stretch/updates/main arm64 Packages
Ign:9 http://deb.debian.org/debian stretch-updates/main arm64 Packages
Ign:12 http://security.debian.org stretch/updates/main all Packages
Ign:11 http://security.debian.org stretch/updates/main arm64 Packages
Ign:12 http://security.debian.org stretch/updates/main all Packages
Ign:11 http://security.debian.org stretch/updates/main arm64 Packages
Ign:10 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:7 http://deb.debian.org/debian stretch/main arm64 Packages
Ign:12 http://security.debian.org stretch/updates/main all Packages
Ign:8 http://deb.debian.org/debian stretch/main all Packages
Ign:9 http://deb.debian.org/debian stretch-updates/main arm64 Packages
Ign:10 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:7 http://deb.debian.org/debian stretch/main arm64 Packages
Ign:8 http://deb.debian.org/debian stretch/main all Packages
Ign:9 http://deb.debian.org/debian stretch-updates/main arm64 Packages
Ign:10 http://deb.debian.org/debian stretch-updates/main all Packages
Ign:7 http://deb.debian.org/debian stretch/main arm64 Packages
Ign:8 http://deb.debian.org/debian stretch/main all Packages
Ign:11 http://security.debian.org stretch/updates/main arm64 Packages
Ign:9 http://deb.debian.org/debian stretch-updates/main arm64 Packages
Ign:12 http://security.debian.org stretch/updates/main all Packages
Ign:10 http://deb.debian.org/debian stretch-updates/main all Packages
Err:7 http://deb.debian.org/debian stretch/main arm64 Packages
404 Not Found
Ign:8 http://deb.debian.org/debian stretch/main all Packages
Err:9 http://deb.debian.org/debian stretch-updates/main arm64 Packages
404 Not Found
Ign:10 http://deb.debian.org/debian stretch-updates/main all Packages
Err:11 http://security.debian.org stretch/updates/main arm64 Packages
404 Not Found
Ign:12 http://security.debian.org stretch/updates/main all Packages
Reading package lists...
W: The repository 'http://security.debian.org stretch/updates Release' does not have a Release file.
W: The repository 'http://deb.debian.org/debian stretch Release' does not have a Release file.
W: The repository 'http://deb.debian.org/debian stretch-updates Release' does not have a Release file.
E: Failed to fetch http://security.debian.org/dists/stretch/updates/main/binary-arm64/Packages 404 Not Found
E: Failed to fetch http://deb.debian.org/debian/dists/stretch/main/binary-arm64/Packages 404 Not Found
E: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/main/binary-arm64/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
Error response from daemon: The command '/bin/sh -c apt-get update && apt-get install -y python-dev python-pip' returned a non-zero code: 100
Failed to deploy '<unknown> Dockerfile: Dockerfile': Can't retrieve image ID from build stream
这个 Dockerfile 过去构建得很好,最近才开始抛出这个错误
答案1
Stretch 已移至 archive.debian.org,您需要更新您的存储库配置或更好,使用较新的基础镜像。
要更新存储库配置,请更改deb.debian.org
为archive.debian.org
引用 Stretch in/etc/apt/sources.list
和 files in 的行/etc/apt/sources.list.d
。
答案2
谢谢@stephen-kitt!我希望他们能够通过此更改更新 docker 镜像:(
如果它对任何人有帮助,我们需要通过python:3.7.3-slim
以下更改来更新我们的 docker 映像 ( ) 以绕过错误(同时仍然能够安装基本软件包):
RUN echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list
至少 PGP 密钥没有被触及......
答案3
感谢@Stephen_Kitt 和@Ben_Kaplan 提供的有用答案!
受它们的启发,我将以下内容添加到我的 Dockerfile 中以切换到 archive.debian.org:
RUN sed -i s/deb.debian.org/archive.debian.org/g /etc/apt/sources.list
RUN sed -i s/security.debian.org/archive.debian.org/g /etc/apt/sources.list
RUN sed -i s/stretch-updates/stretch/g /etc/apt/sources.list
这样,一切工作正常,并且不会弹出任何误导性的错误消息。
编辑:通过下面的评论斯科特·G,仅当没有其他来源列表时,此方法才有效deb.debian.org
。
答案4
对于具有类似问题的节点 12 映像,我还必须添加 debian 安全性才能安装 libnotify
通过添加以下行,我设法让 docker 映像再次工作。
第一行覆盖sources.list中的任何现有内容,其余内容追加到“新”源文件中。
RUN MAJOR_VERSION=$(echo $NODE_VERSION | cut -d '.' -f 1) && \
if [ "$MAJOR_VERSION" = "12" ] ; then \
echo "deb [trusted=yes] http://archive.debian.org/debian stretch main non-free contrib" > /etc/apt/sources.list && \
echo 'deb-src [trusted=yes] http://archive.debian.org/debian/ stretch main non-free contrib' >> /etc/apt/sources.list && \
echo 'deb [trusted=yes] http://archive.debian.org/debian-security/ stretch/updates main non-free contrib' >> /etc/apt/sources.list; \
fi