参考了:https://stackoverflow.com/questions/59139453/repository-is-not-signed-in-docker-build

我尝试在docker中执行 RUN apt-get update && apt-get install -y openssh-server,但总是得到下面的异常:

Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
 At least one invalid signature was encountered.
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
 At least one invalid signature was encountered.
Reading package lists... Done
W: GPG error: http://security.ubuntu.com/ubuntu focal-security InRelease: At least one invalid signature was encountered.
E: The repository 'http://security.ubuntu.com/ubuntu 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.
W: GPG error: http://archive.ubuntu.com/ubuntu focal InRelease: At least one invalid signature was encountered.
E: The repository 'http://archive.ubuntu.com/ubuntu 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://archive.ubuntu.com/ubuntu focal-updates InRelease: At least one invalid signature was encountered.
E: The repository 'http://archive.ubuntu.com/ubuntu 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://archive.ubuntu.com/ubuntu focal-backports InRelease: At least one invalid signature was encountered.
E: The repository 'http://archive.ubuntu.com/ubuntu 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.

如何解决

方案一:

docker image prune并docker container prune解决了这个问题。

方案二:

尝试在docker desktop扩容docker分配的空间,或者删除无用的image。

定位过程

遇到这个无效签名的问题,我首先想到的是应该是国内网络访问不到http://archive.ubuntu.com/ubuntu 下的资源,于是尝试更换apt源为阿里源,但还是依然存在,并报错各种阿里的源没有被签名。

于是,我尝试使用几种VPN,但还是没有效果,这时才想起来google看看错误,发现了这个SO上的问题:

https://stackoverflow.com/questions/59139453/repository-is-not-signed-in-docker-build

通过清理docker,顺利解决这个问题。

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐