以下签名无法验证,因为公钥不可用:NO_PUBKEY 871920D1991BC93C。

7

我试图在Docker中使用Ubuntu 20或Ubuntu 22。我的 Dockerfile 如下:

from ubuntu:22.04
run DEBIAN_FRONTEND=noninteractive apt update

我使用 docker build . 命令构建了这个项目,构建结果如下:
Sending build context to Docker daemon  2.048kB
Step 1/2 : from ubuntu:22.04
---> 2dc39ba059dc
Step 2/2 : run DEBIAN_FRONTEND=noninteractive apt update
---> Running in b15002ae9dd5

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Get:1 http://archive.ubuntu.com/ubuntu jammy InRelease [270 kB] 
Get:2 http://security.ubuntu.com/ubuntu jammy-security 
InRelease [110 kB] 
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB] 
Get:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB] Err:1 http://archive.ubuntu.com/ubuntu jammy InRelease   
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 871920D1991BC93C 

我多次收到这个消息,直到我得到:

W: http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg are ignored as the file is not readable by user '_apt' executing apt-key.

我已尝试将chmod a+rwx /etc/apt -R作为Dockerfile中的第一个run命令,但没有任何改变。
我还明确运行了docker pull ubuntu:22.04,并且它显示已经是最新的。我对ubuntu:20.04镜像也有完全相同的问题。
我已咨询了所有其他涉及此问题的网络资源,但它们都要求我能够运行apt install apt-key或其他内容,但我无法更新apt以开始工作,除了前三页的搜索引擎结果只显示如何在Ubuntu上安装Docker而不是反过来。
我还尝试了--security-opt seccomp:unconfined,如另一个答案中所述。它回应:Error response from daemon: The daemon on this platform does not support setting security options on build
因此,我的镜像没有curlwgetgnupg,我不能在没有解决这个问题的情况下安装它。当我使用apt-key做任何事情时,我得到:E: gnupg、gnupg2和gnupg1似乎未安装,但其中一个是此操作所必需的 我已成功从deb文件手动安装了gnupg,并手动接收了密钥,但出现了类似的错误消息。
# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
Executing: /tmp/apt-key-gpghome.rQuYmKpjpo/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C
gpg: requesting key 991BC93C from hkp server keyserver.ubuntu.com
gpg: key 991BC93C: public key "Ubuntu Archive Automatic Signing Key (2018) <ftpmaster@ubuntu.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA:  1)
W: The key(s) in the keyring /etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg are ignored as the file is not readable by user '' executing apt-key.

我也试过将/etc/apt/source.list修剪到最小。但问题依旧。

我该如何从主机中添加所需的密钥?

另外一个问题是,为什么这样一个主流工具和发行版会出现问题?大家是否已经转向其他工具?如果是,那是什么?由于我没有良好的互联网访问,因此跟上计算机世界的新变化对我来说是个挑战。


这并不是一个与编程或代码相关的问题,应该在Ask Ubuntu上提问。 - Some programmer dude
1
我该如何移动它?这是为了编程,因为它是我需要编译其他东西的基础,我不确定这是一个docker问题还是Debian问题? - WikiLover
1
Askubuntu还说我必须等待40分钟才能发布它,而且它还说我没有足够的声望来添加标签。您是否可以移动它? - WikiLover
你解决过这个问题吗?我似乎也无法在Ubuntu 20.04上安装Docker,原因相同。 - Douglas Gaskell
1个回答

12

只需要升级主机上的Docker。 https://docs.docker.com/engine/install/ubuntu/

这是一种罕见的不兼容性,由于新系统调用保护密钥,老版本的Docker无法支持。无法通过修补Ubuntu来使其在旧版Docker上工作,我尝试了半天也没成功。


请在回答中保持礼貌,不要使用感叹号和大写字母。此外,请更详细地解释需要做什么。单行回答从来都不是一个好选择。 - Tonino

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接