使用 Python:3.8 Docker 映像在 apt-get 更新和安装上开始构建失败,并出现 GPG 错误:bookworm InRelease 未签名

abd*_*wer 6 debian python-3.x docker dockerfile debian-bookworm

我的构建管道突然停止工作,几周前还运行良好。我正在使用 Dockerfile 来构建我的应用程序作为python:3.8基础映像。它已经开始失败了apt-get update && apt-get install。我没有更改 Dockerfile 中的任何内容。

我的 Dockerfile 如下所示:

FROM python:3.8
...
...
...
RUN apt-get update && \
    apt-get install -y default-libmysqlclient-dev libffi-dev libssl-dev git jq tree
...
...
...
Run Code Online (Sandbox Code Playgroud)

以下是我收到的错误:

W: GPG error: http://deb.debian.org/debian bookworm InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131 NO_PUBKEY F8D2585B8783D481
E: The repository 'http://deb.debian.org/debian bookworm InRelease' is not signed.
Run Code Online (Sandbox Code Playgroud)

这是什么原因呢?如何修复它?

abd*_*wer 11

为什么会发生这样的事?

Python docker 镜像最近已更新为使用bookworm2023 年 6 月 10 日发布的 Debian 12 版本,而不是 Debian 10 buster

资料来源:

根本原因是什么?

它是带有 libseccomp 的 Docker,因此 Debian Bookworm 包/库中使用的较新的系统调用被阻止。libseccomp 允许您配置进程允许的系统调用。Docker 为所有容器设置默认的 seccomp 配置文件,以便仅允许某些系统调用,而阻止其他所有内容(因此,libseccomp 或 docker 尚不知道的较新系统调用将被阻止)。

来源:python:3.9 - 从最新版本的映像运行 apt update 失败 #837

可能的解决方案:

任何一个

  • 在 Dockerfile 中添加以下内容:
RUN mv -i /etc/apt/trusted.gpg.d/debian-archive-*.asc  /root/
RUN ln -s /usr/share/keyrings/debian-archive-* /etc/apt/trusted.gpg.d/
Run Code Online (Sandbox Code Playgroud)

或者

  • 使用任何bullseye图像(例如python:3.8-slim-bullseye)。

或者

  • 在运行容器的主机上libseccomp进行更新。docker