`docker-credential-gcloud` not in system PATH

54,249

Solution 1

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.

Solution 2

Just had the same issue on Windows, running Docker with Linux containers, Docker engine v19.03.8. Using docker compose. I do not use gcloud for my dockerfiles...

DT1001 dockerpycreds.errors.InitializationError: docker-credential-gcloud not installed or not available in PATH

  1. Option 1: Edit the docker configuration file and remove all gcloud entries from there.

    • Windows c:/Users/<your account>/.docker/config.json

    • Linux & MacOS ~/.docker/config.json

  2. Option 2: Go to Troubleshoot -> Reset to factory defaults.

After this my docker compose was creating containers and running the images without any issues.

Solution 3

On MacOS

Step 1:

Install gcloud and docker-credential-gcr, following this tutorial

Step 2:

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

Step 3:

$ rm -rf ~/.docker

Step 4:

$ docker-compose build --pull

Finished!

Solution 4

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.

Solution 5

The new version of google-cloud-sdk has only docker-credential-gcr but not docker-credential-gcloud anymore. On the other hand one of my python packages always requested docker-credential-gcloud.

The solution was to symlink docker-credential-gcloud to docker-credential-gcr:

ln -s /path/to/google-cloud-sdk/bin/docker-credential-gcr /usr/local/bin/docker-credential-gcloud

ls -l /usr/local/bin | grep docker should now print:

...
docker-credential-gcloud -> /path/to/google-cloud-sdk/bin/docker-credential-gcr
...
Share:
54,249
ZaxR
Author by

ZaxR

Updated on July 05, 2022

Comments

  • ZaxR
    ZaxR almost 2 years

    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 as per the instructions after updating gcloud, I get the following message:

    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.
    

    Running which docker-credential-gcloud returns docker-credential-gcloud not found.

    I have no other gcloud-related path issues and for the life of me can't figure out how to install/add docker-credential-gcloud to path. Here's what I have installed (shown via gcloud version):

    Google Cloud SDK 197.0.0
    beta 2017.09.15
    bq 2.0.31
    container-builder-local
    core 2018.04.06
    docker-credential-gcr
    gsutil 4.30
    

    I also have Docker CE Version 18.03.0-ce-mac60 (23751).

    Here's my $PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

    I also ran source /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc on original gcloud install.

  • jumand
    jumand about 6 years
    This answer almost worked for me, but needed a tweak. The symlink step seemed to have an outdated/typo in it. It referenced docker-credential-gcr instead of docker-credential-gcloud. Updating that step as below worked for me. $ ln -s /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk‌​/bin/docker-credenti‌​al-gcloud /usr/local/bin/
  • Xiwen Li
    Xiwen Li about 6 years
    Thank you Jumand for noticing it. It was pure type. I am having it corrected.
  • Xiwen Li
    Xiwen Li about 6 years
    I just checked. On my machine it is docker-credential-gcr. And I ran gcloud components list docker-credential-gcloud isn't there. I don't know what's going on.
  • Maximilian
    Maximilian about 6 years
    @jumand - I think that docker-credential-gcr is the new tool, and -gcloud is the deprecated one. See cloud.google.com/container-registry/docs/…
  • Praxiteles
    Praxiteles almost 6 years
    On executing statement 3 we received this warning. Any concern? "...WARNING: Unable to execute docker version: exit status 1 This is expected if docker is not installed, or if dockerd cannot be reached..."
  • ZaxR
    ZaxR almost 6 years
    I don't remember encountering that, but the accepted answer makes a lot more sense than this one I think
  • Inbar Rose
    Inbar Rose about 5 years
    for me it was not in /usr/local/Caskroom/ but in /snap/ (using ubuntu)
  • asdfqwer
    asdfqwer over 3 years
    This worked for me. For the love of god I couldn't find the executable and was about to clone and run the repo. After extracting ran: ./google-cloud-sdk/bin/gcloud init then ./google-cloud-sdk/bin/gcloud components install docker-credential-gcr then just add the bin to your $PATH
  • Amir Chatrbahr
    Amir Chatrbahr over 3 years
    I had to make credHelpers empty "credHelpers":{}. thanks worked for me.
  • Dirk
    Dirk about 3 years
    I also cleared "credHelpers":{} as mentioned by @amir-chatrbahr, but it was filled again. I assume it can come from updating Docker Desktop or IntelliJ (where I have an unconfigured GCloud plugin)?
  • bzani
    bzani about 3 years
    I was having the same problem trying to docker-compose build locally, after uninstalling gcloud, so after removing both files it worked fine: /usr/bin/docker-credential-gcloud and ~/.docker/config.json
  • av-k
    av-k about 2 years
    Helped just to remove ~/.docker/config.json and restart Docker.