修复 gcloud WARNING: `docker-credential-gcloud` not in system PATH

问题:

你想配置 docker 以便能够使用以下命令访问 Google Container Registry

gcloud_configure_docker.sh
gcloud auth configure-docker

但你看到此警告消息:

gcloud_warning.txt
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.
gcloud credential helpers already registered correctly.

解决方案

使用以下命令安装 docker-credential-gcloud

install_docker_credential_gcr.sh
sudo gcloud components install docker-credential-gcr

如果你看到此错误消息:

gcloud_components_error.txt
ERROR: (gcloud.components.install) You cannot perform this action because this Cloud SDK installation is managed by an external package manager.
Please consider using a separate installation of the Cloud SDK created through the default mechanism described at: https://cloud.google.com/sdk/

请使用此备用安装命令(此命令适用于 Linux,其他操作系统请参见官方文档):

install_docker_credential_gcr_alt.sh
VERSION=1.5.0
OS=linux
ARCH=amd64

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/bin/docker-credential-gcr > /dev/null && sudo chmod +x /usr/bin/docker-credential-gcr

之后,使用以下命令配置 docker

docker-credential-gcr configure-docker

docker_credential_configure.sh
docker-credential-gcr configure-docker

现在你可以重试运行你的原始命令。

供参考请参见官方文档


Check out similar posts by category: Cloud, Container, Docker, Linux