首页 > 解决方案 > 设置gcloud缓存use_kaniko后权限无效?

问题描述

我在云端构建 Docker 镜像时遇到了一个奇怪的权限错误。我切换到另一台机器,安装了 Gcloud,做了 gcloud init,一切都恢复了。

但是,我注意到在构建图像时,它花费了更长的时间,因为我没有启用 kaniko 缓存(我从这篇文章中了解到:gcloud rebuilds complete container but Dockerfile is the same, only the script has changed

启用此功能后,我尝试重建我的最后一个图像和 bam,同样的错误消息:

Status: Downloaded newer image for gcr.io/kaniko-project/executor:latest

gcr.io/kaniko-project/executor:latest 

error checking push permissions -- 
make sure you entered the correct tag name, and that you are authenticated correctly, and try again: 

checking push permission for "eu.gcr.io/pipeline/tree-par": creating push check transport for eu.gcr.io failed: 
GET https://eu.gcr.io/v2/token?scope=repository%3pipeline%2Ftree-par%3Apush%2Cpull&service=eu.gcr.io:

UNAUTHORIZED: You don't have the needed permissions to perform this operation, and you may have invalid credentials.
To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication 

ERROR

ERROR: build step 0 "gcr.io/kaniko-project/executor:latest" failed: step exited with non-zero status: 1
-------------------------------------------------------------------------------------------------------------------------------

ERROR: (gcloud.builds.submit) build bad4a9a4-054d-4ad7-991d-e5aeae039b7c completed with status "FAILURE"

任何人都知道为什么在启用 Kaniko 缓存时会失败?我讨厌不使用它,因为当它仍然有效时,它确实减少了创建 docker 映像所需的时间。

标签: gcloudkaniko

解决方案


看来问题出在 Kaniko 的头上。

三天前,在v0.21.0版本上,他们添加了这个修复:

修复:GCR 凭证助手检查不尊重 DOCKER_CONFIG 环境变量

即使在此版本发布后 1 天后,也报告了此问题,用户看到了非常相似的错误消息:

“[...] 您没有执行此操作所需的权限,并且您的凭据可能无效[...]”

昨天发布的v0.22.0版本已经解决了这个问题。建议的解决方法是执行以下命令:

gcr.io/kaniko-project/executor:v0.22.0

我建议使用该命令而不是executor:latest“强制”使用 v0.22.0 版本。

我希望这是有帮助的!:)


推荐阅读