在 Docker 构建中访问 Debian 存储库:“由于公钥不可用,无法验证以下签名”

在 Docker 构建中访问 Debian 存储库:“由于公钥不可用,无法验证以下签名”

当我尝试构建以下 Dockerfile 时

FROM debian:bullseye

RUN set -eux; \
    apt update; \
    apt install -y --no-install-recommends ca-certificates;

RUN set -eux; \
    echo "deb https://nginx.org/packages/mainline/debian/ bullseye nginx" >> /etc/apt/sources.list.d/nginx.list;

RUN set -eux; \
    apt update;

我收到错误:

#0 1.077 Err:4 https://nginx.org/packages/mainline/debian bullseye InRelease
#0 1.077   The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ABF5BD827BD9BF62
#0 1.082 Reading package lists...
#0 1.348 W: GPG error: https://nginx.org/packages/mainline/debian bullseye InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ABF5BD827BD9BF62
#0 1.348 E: The repository 'https://nginx.org/packages/mainline/debian bullseye InRelease' is not signed.

是否有一个合理简单的方法可以访问 Docker 构建中的 nginx 包存储库?

答案1

将 nginx 存储库配置为“受信任”存储库:

FROM debian:bullseye

RUN set -eux; \
    apt update; \
    apt install -y --no-install-recommends ca-certificates;

RUN set -eux; \
    echo "deb [trusted=yes] https://nginx.org/packages/mainline/debian/ bullseye nginx" >> /etc/apt/sources.list.d/nginx.list;

RUN set -eux; \
    apt update;

将存储库配置为“受信任”意味着不需要 GPG 检查。

相关内容