我在云端构建 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 映像所需的时间。