首页 > 解决方案 > Error pulling docker image from GCR: "You don't have the needed permissions to perform this operation, and you may have invalid credentials."

问题描述

I am SSH'd into a GCE instance in Project A whose service account has Storage Admin access in Project B, where Image Foo is located. When I run docker build . from the command line of my GCE instance, I get the above error when docker tries to pull Image Foo from Project B. I have configured docker according to the instructions in the link, and authenticated using gcloud.

标签: gcloud

解决方案


我怀疑这是两件事中的一两个:

首先,检查您在 VM 上运行的帐户 ( gcloud auth list)。这可能是 VM 的服务帐户而不是您的用户帐户。这是需要 IAM'd 到存储桶的帐户;

其次,确保您已将 docker 配置为访问 GCR 的帐户凭据(如果可能:)gcloud auth configure-docker

然后,它应该工作。

我重现了您的错误并应用了这些更改并且它有效(链接)


推荐阅读