![在 Docker 构建中访问 Debian 存储库:“由于公钥不可用,无法验证以下签名”](https://linux22.com/image/786552/%E5%9C%A8%20Docker%20%E6%9E%84%E5%BB%BA%E4%B8%AD%E8%AE%BF%E9%97%AE%20Debian%20%E5%AD%98%E5%82%A8%E5%BA%93%EF%BC%9A%E2%80%9C%E7%94%B1%E4%BA%8E%E5%85%AC%E9%92%A5%E4%B8%8D%E5%8F%AF%E7%94%A8%EF%BC%8C%E6%97%A0%E6%B3%95%E9%AA%8C%E8%AF%81%E4%BB%A5%E4%B8%8B%E7%AD%BE%E5%90%8D%E2%80%9D.png)
当我尝试构建以下 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 检查。