After the latest updates to gcloud and docker I\'m unable to access images on my google container repository. Locally when I run: gcloud auth configure-docker
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.
Usually, this error indicates that your $PATH
variable has been clobbered by a package or program you have recently installed so that the Google Cloud SDK can't be found.
$PATH
is altered by many programs when they install by altering ~/.profile
, ~/.bash_profile
or ~/.bashrc
or their non-bash equivalents. With a bad $PATH
, Google Cloud SDK is configured in docker
but can't be seen as executables so we get this error. This assumes you have used the Google Cloud SDK in the past, but if gcloud
is configured with your docker then you probably have. Don't reinstall gcloud or disable it, you already have it on your system and that is fine.
The solution then is to fix your $PATH
, not to install anything.
echo $PATH
This should be a pretty long :
delimited list of directories that your files are in. Do you see a google-cloud-sdk/bin
in the string? Is the string way too short given all the trouble you've gotten into in your life on this computer? You use NVM but it is missing? Use Homebrew but it is missing? Try brew
from the command line, does it work?
If the answer is "no" to any of the above, inspect the files above to see if there are any new entries at the bottom of each that might have broken things. Did you just install anything new?
Something is clobbering your $PATH
and you need to figure out what that is. For me it is usually something to do with Anaconda Python via the conda init
command. For you it might be nvm
or something else. Figure out what it is and fix the problem. Don't start over with a new $PATH
and install the same stuff over again or disable gcloud
authentication.
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
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:
gcloud components install docker-credential-gcr
, docker-credential-gcr configure-docker
.screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
umount /var/lib/docker/overlay2
rm -rf /var/lib/docker