`docker-credential-gcloud` not in system PATH

ぐ巨炮叔叔 提交于 2019-11-30 10:49:41

Notice: All docker-credential-gcr below can be replaced with docker-credential-gcloud. I think it is just different versions of gcloud, I might be wrong.

I used Homebrew Cask to install gcloud too. I installed docker-credential-gcr with

$ gcloud components install docker-credential-gcr

And then like you said, which docker-credential-gcr doesn't gave you anything.

So I ran which gcloud to find there is a symlink to gcloud in /usr/local/bin. This symlink is created by Homebrew when you installed gcloud at first place. Now docker-credential-gcr wasn't installed by Homebrew but by gcloud itself, so there isn't a symlink.

I called readlink /usr/local/bin/gcloud and found out gcloud is installed in /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin/.

Then:

$ ls /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin

There you should see docker-credential-gcr listed there.

I simply linked it to /usr/local/bin:

$ ln -s /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin/docker-credential-gcr /usr/local/bin/

Then run:

$ docker-credential-gcr configure-docker

It should succeed.

Never found a way to directly resolve the docker-credential-gcloud issue, but the following got me up and running again. WARNING: the following will delete all your existing docker images and install a bunch of gcloud utilities:

  1. gcloud components install docker-credential-gcr,
  2. Restart the terminal completely
  3. docker-credential-gcr configure-docker.
  4. screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

  5. umount /var/lib/docker/overlay2

  6. rm -rf /var/lib/docker
  7. Restart the terminal completely.

It really seems to be something with the Homebrew Cask. I uninstalled the cask and then reinstalled the Google Cloud SDK by manually downloading the tar ball and running the packaged install script as described there.

Now docker-credential-gcloud is in my path:

$ which docker-credential-gcloud
/Users/moritz/google-cloud-sdk/bin/docker-credential-gcloud

I got the issue when I tried to SSH from Google Cloud Build into an Engine VM Instance, so I had

steps:
- name: 'gcr.io/cloud-builders/gcloud'
  args: ['compute', 'ssh',
         '--project', '$PROJECT_ID',
         '--zone', 'asia-southeast1-b',
         '--strict-host-key-checking=no',
         'username@instance-1',
         '--command' ,'sh start.sh'

My start.sh

#!/bin/sh

echo "Started: $(date --iso-8601=seconds)"

docker pull gcr.io/aaa/bbbc/cccc

echo "Finished: $(date --iso-8601=seconds)"

The issue was How to set PATH when running a ssh command?

https://unix.stackexchange.com/questions/332532/how-to-set-path-when-running-a-ssh-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!