从Ubuntu 20.04上GCE vm内的GCR中提取

问题描述 投票:0回答:1

我已经有一段时间没有建立GCE堆栈了,我发誓随着时间的推移这会变得越来越困难。因此设置非常简单:空白的ubuntu VM,通过snap安装docker。现在,当我尝试从GCR拉出时,我得到

> docker pull gcr.io/.../image
Using default tag: latest
Error response from daemon: 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

足够。我检查了我的gcloud命令:

> gcloud auth list
                  Credentialed Accounts
ACTIVE  ACCOUNT
*       [email protected]

To set the active account, run:
    $ gcloud config set account `ACCOUNT`

所以正确的服务帐户在那里。在IAM中,它被列为编辑器,并且在很好的情况下,我也添加了存储管理员。现在我运行

> gcloud auth configure-docker
WARNING: `docker-credential-gcloud` not in system PATH.
gcloud's Docker credential helper can be configured but it will not work until this is corrected.
Adding credentials for all GCR repositories.
WARNING: A long list of credential helpers may cause delays running 'docker build'. We recommend passing the registry name to configure only the registry you are using.
After update, the following will be written to your Docker config file
 located at [/home/y/.docker/config.json]:
 {
  "credHelpers": {
    "gcr.io": "gcloud", 
    "marketplace.gcr.io": "gcloud", 
    "eu.gcr.io": "gcloud", 
    "us.gcr.io": "gcloud", 
    "staging-k8s.gcr.io": "gcloud", 
    "asia.gcr.io": "gcloud"
  }
}

Do you want to continue (Y/n)?  

Docker configuration file updated.

并且根据gcp的文档,警告很好。 gcloud可以用作独立帮助程序的替代方法。但仍然:拉力失败。闷闷不乐。

根据文档,sudo是个坏主意。因此,我尝试将用户添加到docker组中,并且显然与snap发生冲突。我跑

> sudo addgroup --system docker
> sudo adduser $USER docker
> newgrp docker

> sudo snap disable docker
> sudo snap enable docker

所以现在我可以将docker与我的帐户一起使用了。问题仍然存在。我也尝试过使用[]

> VERSION=2.0.0
> OS=linux  # or "darwin" for OSX, "windows" for Windows.
> ARCH=amd64  # or "386" for 32-bit OSs, "arm64" for ARM 64.
> curl -fsSL "https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v${VERSION}/docker-credential-gcr_${OS}_${ARCH}-${VERSION}.tar.gz" | tar xz --to-stdout ./docker-credential-gcr | sudo tee /usr/local/bin/docker-credential-gcr && sudo chmod +x /usr/local/bin/docker-credential-gcr

> docker-credential-gcr configure-docker

我对此进行了很长时间的故障排除,这是怎么回事?

我已经有一段时间没有建立GCE堆栈了,我发誓随着时间的推移这会变得越来越困难。因此设置非常简单:空白的ubuntu VM,通过snap安装docker。现在,当我尝试从GCR拉出时,我得到&...

docker google-cloud-platform google-compute-engine gcloud google-cloud-sdk
1个回答
0
投票

Snap似乎引起了这里的问题。在辅助程序的特定于快照的配置文件和快速安装gcloud SDK之间的某个位置,发生了错误。我进行了全新安装,仅安装了apt:

© www.soinside.com 2019 - 2024. All rights reserved.