Docker构建时出现“Repository is not signed”的问题

205

我有一个Dockerfile,使用从dockerhub拉取的最新Ubuntu镜像:

FROM ubuntu:latest  
RUN apt-get update  && apt-get install -y  g++ llvm lcov 

当我执行docker build命令时,会出现以下错误:
Err:2 http://archive.ubuntu.com/ubuntu bionic InRelease 
At least one invalid signature was encountered.

Err:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
  At least one invalid signature was encountered.

Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
  At least one invalid signature was encountered.

Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
  At least one invalid signature was encountered.

Reading package lists...

W: GPG error: http://archive.ubuntu.com/ubuntu bionic InRelease: At least one invalid signature was encountered.
E: The repository 'http://archive.ubuntu.com/ubuntu bionic InRelease' is not signed.

W: GPG error: http://security.ubuntu.com/ubuntu bionic-security InRelease: At least one invalid signature was encountered.
E: The repository 'http://security.ubuntu.com/ubuntu bionic-security InRelease' is not signed.

W: GPG error: http://archive.ubuntu.com/ubuntu bionic-updates InRelease: At least one invalid signature was encountered.
E: The repository 'http://archive.ubuntu.com/ubuntu bionic-updates InRelease' is not signed.

W: GPG error: http://archive.ubuntu.com/ubuntu bionic-backports InRelease: At least one invalid signature was encountered.
E: The repository 'http://archive.ubuntu.com/ubuntu bionic-backports InRelease' is not signed.

我在这里阅读到https://superuser.com/questions/1331936/how-can-i-get-past-a-repository-is-not-signed-message-when-attempting-to-upgr,据说你可以使用--allow-unauthenticated或--allow-insecure-repositories通过此错误,但这两种方法似乎都是权宜之计,可能会危及容器的安全性。 编辑 尝试拉取ubuntu:18.04、ubuntu:19:04、ubuntu:19.10,不同发行版名称但出现相同错误。

你是在代理服务器后面工作吗? - 7_R3X
@7_R3X 不,完全不是。 - Antonio La Marra
除了使用latest,您尝试过ubuntu:18.04吗? - Govinda Malavipathirana
是的,我尝试过19.04和19.10。 - Antonio La Marra
我尝试拉取一个更新的镜像,成功了。看起来镜像中有一些 bug。 - Sergey Ponomarev
14个回答

1

现有的答案都谈到通过使用docker container prunedocker image prunedocker volume prune来删除现有的Docker项目,以便为Docker创建更多的空间。或者,如果您有足够的磁盘空间,也可以增加Docker为自身设置的磁盘限制。

在Docker桌面版中,转到设置 > 资源并增加"虚拟磁盘限制"。

这对我很有帮助,因为我使用了几个大型的Docker镜像,不想每次都进行修剪操作。


0

这对我有用: docker system prune -af --volumes 还有这些:

docker image prune 
docker container prune
docker builder prune
docker volume prune

运行 docker system df 命令,查看您的卷中是否需要释放空间。


0

我通过停止所有正在运行的容器(在我的情况下为2个)来解决了这个问题。


-1
我在构建命令中添加了--network=host
docker build --network=host -t REPOSITORY:TAG  ./

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