首页 > 解决方案 > 无法从 GCP Container Registry 拉取镜像

问题描述

我正在尝试docker pull从 GCP 容器注册表。

版本:

username@this_machine:~$ docker --version
Docker version 1.9.1, build a34a1d5
username@this_machine:~$ gcloud --version
Google Cloud SDK 319.0.0
alpha 2020.11.13
beta 2020.11.13
bq 2.0.62
core 2020.11.13
gsutil 4.55
kubectl 1.16.13
username@this_machine:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.6 LTS
Release:        14.04
Codename:       trusty
username@this_machine:~$ gcloud auth configure-docker
WARNING: Your config file at [/mnt/ext4/users/username/.docker/config.json] contains these credential helper entries:

{
  "credHelpers": {
    "gcr.io": "gcloud",
    "us.gcr.io": "gcloud",
    "eu.gcr.io": "gcloud",
    "asia.gcr.io": "gcloud",
    "staging-k8s.gcr.io": "gcloud",
    "marketplace.gcr.io": "gcloud"
  }
}
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.
gcloud credential helpers already registered correctly.
username@this_machine:~$ docker pull eu.gcr.io/gcp-project-1/my_docker_image
Using default tag: latest
Pulling repository eu.gcr.io/gcp-project-1/my_docker_image
Error: Status 405 trying to pull repository gcp-project-1/my_docker_image: "v1 Registry API is disabled. If you are not explicitly using the v1 Registry API, it is possible your v2 image could not be found. Verify that your image is available, or retry with `dockerd --disable-legacy-registry`. See https://cloud.google.com/container-registry/docs/support/deprecation-notices"
username@this_machine:~$ docker pull eu.gcr.io/gcp-project-1/my_docker_image:latest
Pulling repository eu.gcr.io/gcp-project-1/my_docker_image
Error: Status 405 trying to pull repository gcp-project-1/my_docker_image: "v1 Registry API is disabled. If you are not explicitly using the v1 Registry API, it is possible your v2 image could not be found. Verify that your image is available, or retry with `dockerd --disable-legacy-registry`. See https://cloud.google.com/container-registry/docs/support/deprecation-notices"

当我运行docker pull python它的工作。所以它可以从 docker hub 获取,而不是 gcp。

我已经完成gcloud auth login并尝试了具有正确权限的服务帐户(这一切都适用于其他所有机器)

我认为我的 cloudSDK 或 docker 安装已损坏。但我不知道,所以如果有任何想法,我将不胜感激。

标签: dockergoogle-cloud-platformubuntu-14.04google-container-registry

解决方案


您使用的 Docker 版本 1.9.1 确实过时了,它甚至不再列在Docker 页面中,我建议您先升级到更新版本的 docker,然后再试一次。

您可以按照本指南根据您的操作系统执行升级。

此外,添加标志“--disable-legacy-registry”似乎是一个常见错误,但没有明确启用或禁用它,该标志的正确用法是:

--disable-legacy-registry=true or --disable-legacy-registry=false

在这种情况下,您似乎需要将其设置为“true”。


推荐阅读