在ARM架构的Ubuntu 20.04容器中,执行apt update命令会出现签名错误。

我正在尝试构建树莓派的Docker镜像,但总是遇到相同的错误,类似于this onethis onethis one
在以root身份在arm32v7/ubuntu:20.04(或者只是ubuntu:latest)上运行apt update命令时,我得到以下输出:
root@273d63597ce6:/# apt update
Get:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease [265 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease [111 kB]
Get:3 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease [98.3 kB]
Get:4 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease [107 kB]
Err:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease
  At least one invalid signature was encountered.
Err:2 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease
  At least one invalid signature was encountered.
Err:3 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease
  At least one invalid signature was encountered.
Err:4 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease
  At least one invalid signature was encountered.
Reading package lists... Done
W: GPG error: http://ports.ubuntu.com/ubuntu-ports focal InRelease: At least one invalid signature was encountered.
E: The repository 'http://ports.ubuntu.com/ubuntu-ports focal InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease: At least one invalid signature was encountered.
E: The repository 'http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease: At least one invalid signature was encountered.
E: The repository 'http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://ports.ubuntu.com/ubuntu-ports focal-security InRelease: At least one invalid signature was encountered.
E: The repository 'http://ports.ubuntu.com/ubuntu-ports focal-security InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

我已经尝试了清理apt、清理docker以及删除/重新创建/var/lib/apt/lists等建议的解决方案,但都没有成功。SD卡容量为32G,并进行了全新安装的操作系统。df命令显示有26G可用空间。
以下是一些更多的信息:
- 这个问题发生在一个全新安装的2020-05-27-raspios-buster-lite-armhf系统上的树莓派4B上。 - 同样的错误也发生在另一个运行HypriotOS的树莓派4B上。 - 在安装有Arch Linux的树莓派3B上,同样的命令和镜像可以正常工作。 - 如果使用较旧版本的Ubuntu(如ubuntu:18.04,16.04,14.04),则不会出现此错误。

谢谢回复!我觉得这不是修剪图像的方法,但我尝试了docker image rm ubuntu:20.04docker system prune -a -f,但问题没有解决。 - TSpark
7对我来说,我在docker4mac中的磁盘空间已经用完了,只需要运行docker system prune命令即可。 - Callum Rogers
4个回答

问题的根本原因在于libseccomp。更新的版本修复了这个问题,但是尚未在Debian的稳定软件源中可用。有两种方法可以解决这个问题:

方法一

使用--privileged选项启动容器。这将绕过Docker的安全措施,因此不建议使用。或者使用--security-opt seccomp:unconfined选项作为稍微安全一点的选择。 docker run -it --security-opt seccomp:unconfined ubuntu:latest

方法二

在主机系统上手动升级libseccomp。从不稳定的软件源中下载版本(我测试过2.4.3-1)here

安装新版本:

sudo dpkg -i libseccomp2_2.4.3-1+b1_armhf.deb

注意:上述方法解决了基于Raspbian系统的问题。在一个Ubuntu 20.04 aarch64系统上也出现了相同的错误,@NeonLines的答案能够提供帮助。

4"Method 2" 在这个答案中的描述是有帮助的,尽管还不清楚我需要在 Raspberry Pi 主机系统上进行 libseccomp2 的升级还是在 Docker 镜像中:它需要在 RaspiOS 主机系统中进行升级。强制清除旧版本是不必要的,使用 dpkg -i 进行升级,在不先卸载旧版本的情况下也可以成功。 - Ludwig Schulze
2好知道!我已经更新了答案以反映这一点。 - TSpark
3谢谢,方法2在我的树莓派3上有效。 - Evgeny Bobkin
2刚刚将它升级到2.4.4-1~bpo10+1,然后它就正常工作了。我使用的是树莓派操作系统(debian)Buster版本。感谢您的回答。https://packages.debian.org/buster-backports/libseccomp2 - Giovanni Bassi
4太神奇了,我刚在主机rpi上运行了这个命令,而不需要重新启动容器。cd /tmp;wget http://ftp.us.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.5.1-1_armhf.deb;sudo dpkg -i libseccomp2_2.5.1-1_armhf.deb - Philippe Gachoud

至少遇到了一个无效的签名。
错误提示表明,在/var/lib/apt/lists目录中的文件中,至少有一个无效/损坏的签名(可能是apt-key的误用或其他原因导致的)。
尝试以调试模式运行Apt更新命令:
apt-get -oDebug::pkgAcquire::Worker=1 update

这应该会指向损坏的文件,例如:

0%[正在工作] <- gpgv:400%20URI%20Failure%0aMessage:至少遇到一个无效签名。 %0aURI:gpgv:/ var / lib / apt / lists / partial / CorruptedFile_InRelease

编辑文件,查找并删除已损坏的部分或整个文件,以便可以重新创建。


TSpark的、HyperCreeks的和ibster1st123s的答案对我在Rasbian 10和官方仓库中的最新docker版本上都有效。正如NeonLines指出的那样,您必须安装一个最新版本,因为它们不会遇到这个问题。
大多数用户都会设置Docker的仓库并从中安装,以便于安装和升级任务。这是推荐的方法,但对于Raspbian来说不适用。[...] 对于Raspbian,尚不支持使用仓库进行安装。相反,您必须使用方便脚本。
tl;dr 使用方便脚本获取最新的docker版本。不过,您应该检查上面的链接,因为有一些注意事项。
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

升级到 Docker 版本 19.03.12 解决了我的问题。

谢谢答案!这是我目前正在使用的版本。你从哪个版本升级过来的?请问你的 docker --version 命令返回的构建号是多少? - TSpark
正在运行build 48a6621。编辑:此版本还在运行20.04.1,但我已确认它也适用于20.04。 - NeonLines
升级过程中,我按照这里的步骤进行操作,主要是重新获取密钥以及删除所有先前安装的软件包。我相信docker-ce现在已经更名为docker-ce-cli,如果您仍然安装了旧版本的docker-ce或其他软件包,这也可能造成问题。 - NeonLines
1重新安装并获取密钥没有解决问题。你真的在运行树莓派吗?而且你能够在Ubuntu Focal Docker容器中运行apt update吗?此外,如果是这种情况,你如何指定一个20.04.1映像?对我来说似乎不存在。 - TSpark
看起来这个解决方案确实解决了我之前遇到的另一台机器的问题。谢谢! - TSpark
1在树莓派上,我已经安装了docker-ce和docker-ce-cli的版本为5:19.03.123-0raspbian-buster,并且在尝试使用ubuntu:20.04镜像时仍然遇到了与问题描述完全相同的问题。很抱歉,但这个答案没有帮助到我。 - Ludwig Schulze