gpt4 book ai didi

docker - Google 容器注册表权限

转载 作者:行者123 更新时间:2023-12-02 19:21:12 30 4
gpt4 key购买 nike

我正在尝试将 docker 镜像推送到 GCP,但我仍然收到此错误:

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

明确GCP项目

我已经尝试过:

  1. 将 gcloud 用作 Docker 凭证助手:gcloud auth configure-docker
  2. 重新安装 Cloud SDK 和 gcloud init
  3. Storage Admin 角色添加到我的帐户

我做错了什么?

谢谢你的建议

最佳答案

如果能帮到和我一样情况的人:

  • Docker 19.03
  • 谷歌云 SDK 288.0.0

Important: My user is not in a docker user group. I then have to prepend sudo before any docker command

gclouddocker 不使用相同的 config.json 时

当我使用 gcloud 凭证助手时:

gcloud auth configure-docker

它会更新我的 $HOME 中的 JSON 配置文件:[/home/{username}/.docker/config.json]。但是,当从 Docker CLI 注销并再次登录时,

sudo docker login

警告显示了不同的路径,这很有意义,因为我 sudo-ed:

WARNING! Your password will be stored unencrypted in /root/.docker/config.json.

sudo 无处不在

为了修复它,我执行了以下步骤:

# 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 hub

关于docker - Google 容器注册表权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59592243/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com