在 arm32v7/ubuntu:20.04 docker 内运行 apt update 时出现 GPG 签名错误

14

我正在尝试从Ubuntu16升级到Ubuntu20,为此我需要在所有Dockerfiles中将图像arm32v7/ubuntu:16.04更改为arm32v7/ubuntu:20.04 [更新所需的库],但是在完成这项任务时,我发现Ubuntu:20.04的arm32v7基础镜像存在问题 - 当我运行apt-get update时,会出现以下错误消息-

Err:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease
  At least one invalid signature was encountered.
Get:4 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease [107 kB]
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.

我尝试了这里提到的解决方案[https://askubuntu.com/a/1264921/872700],但由于我们在Dockerfile中使用镜像,所以不允许在docker build命令中传递--security-opt选项,因此该解决方案也无法正常工作。
作为解决方法,我使用--security-opt选项运行了docker run,并创建了另一个镜像,然后在新镜像中运行了apt-get update,但这也不起作用。
FYI,该机器上有以下docker版本- Docker version 19.03.13, build 4484c46

检查 AskUbuntu 上的重复问题 https://askubuntu.com/questions/1263284/apt-update-throws-signature-error-in-ubuntu-20-04-container-on-arm - Pipo
同样的问题出现在 PHP8 Docker 容器中。 - til
2个回答

62
我最近在Docker Desktop for Mac上遇到了这个问题,在一个Ubuntu 20.04 x86_64容器中运行apt-get update命令时出现了问题。结果发现MacOS上托管Docker镜像的虚拟机磁盘空间已经用完,导致apt报告包索引文件的签名无效。清理未使用的镜像以释放空间解决了我的问题:

docker image prune -a

正如sema评论中所提到的,如果问题是由于磁盘空间不足引起的,则另一种解决方法是增加运行Docker的虚拟机使用的虚拟磁盘的大小。在Docker Desktop for Mac中,可以通过 Preferences > Resources > Disk image size来完成此操作。

1
我和楼主遇到了完全相同的问题,这个解决方案很有效。此外,增加图像的磁盘空间也可以帮助解决问题:首选项 > 资源 > 磁盘映像大小。 - sema
1
docker system prune -a 将删除未使用的容器并清理大量空间。我遇到了这个问题,运行这个命令解决了问题,并清除了30GB的文件。 - dardo
2
哇,该死,非常感谢你指出这个问题,这可能为我节省了几个小时的灵魂探索。 - jlos

13
为解决这个问题,我不得不更新主机树莓派上的库libseccomp2,因为我找不到其他可在基础镜像中应用的解决方案。

这里下载了deb包,然后使用以下命令在主机上应用:

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


这个功能什么时候会默认推出呢? - starbeamrainbowlabs
更新:如果您设置了Debian Backports,那么运行 sudo apt-get install -t buster-backports libseccomp2 将安装一个新版本的 libseccomp2 来修复此问题。为了保险起见,我还重新启动了 dockercontainerdsudo systemctl restart containerd docker - starbeamrainbowlabs
1
在askubuntu上有重复的答案:https://askubuntu.com/questions/1263284/apt-update-throws-signature-error-in-ubuntu-20-04-container-on-arm - Pipo

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