Google Container Registry权限 [英] Google Container Registry permission
问题描述
我正在尝试将Docker映像推送到GCP,但仍然出现此错误:
I am trying to push docker image to GCP, but i am still getting this error:
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
我遵循此 https://cloud.google.com/container-registry/docs/quickstart 逐步进行,一切正常,直到docker push
I follow this https://cloud.google.com/container-registry/docs/quickstart step by step and everything works fine until docker push
这是明确的GCP项目
我已经尝试过:
- 使用gcloud作为Docker凭证帮助器:
gcloud auth configure-docker
- 重新安装Cloud SDK和
gcloud init
- 向我的帐户添加存储管理员角色
- use gcloud as a Docker credential helper:
gcloud auth configure-docker
- reinstall Cloud SDK and
gcloud init
- add Storage Admin role to my account
我做错了什么?
谢谢您的建议
推荐答案
如果它可以帮助那些与我一样的人:
If it can help those in the same situation as me:
- Docker 19.03
- Google云SDK 288.0.0
重要:我的用户不在 docker 用户组中.然后,我必须在任何docker命令之前添加
sudo
Important: My user is not in a docker user group. I then have to prepend
sudo
before any docker command
当gcloud
和docker
没有使用相同的config.json
当我使用gcloud凭据助手时:
When gcloud
and docker
are not using the same config.json
When I use gcloud credential helper:
gcloud auth configure-docker
它更新$ HOME中的JSON配置文件:[/home/{username}/.docker/config.json]
.但是,从Docker CLI注销并再次登录时,
it updates the JSON config file in my $HOME: [/home/{username}/.docker/config.json]
. However, when logging out and login again from Docker CLI,
sudo docker login
警告显示了一条不同的路径,这与我sudo
-ed:
The warning shows a different path, which makes sense as I sudo
-ed:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
sudo
到处都是
要解决此问题,我执行了以下步骤:
sudo
everywhere
To fix it, I did the following steps:
# Clear everything
sudo docker logout
sudo rm /root/.docker/config.json
rm /home/{username}/.docker/config.json
# Re-login
sudo docker login
sudo gcloud auth login --no-launch-browser # --no-launch-browser is optional
# Check both Docker CLI and gcloud credential helper are here
sudo vim /root/.docker/config.json
# Just in case
sudo gcloud config set project {PROJECT_ID}
我现在可以将Docker映像同时推送到GCR和Docker集线器
I can now push my Docker images to both GCR and Docker hub
这篇关于Google Container Registry权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!