Handling Credentials Store Errors w/ Docker Credential GCloud on GCP

Publication Date | September 09, 2020
Last Updated | September 09, 2020

The current build process for writeup.ai and betterself.io is :

  1. I push code to a repo.
  2. Google Build mirrors the repo. When suitable build changes are detected, it kicks off a build on Google Build.
  3. When deploying to cloud instances, they will pull the latest builds from Google Build.

That works 99% of the time. Sometimes, I will want to debug something on the instance/VM itself that's when I receive cryptic errors from docker-credential-gcloud ...

subprocess.CalledProcessError: Command '['/usr/local/bin/docker-credential-gcloud', 'get']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "site-packages/docker/auth.py", line 264, in _resolveauthconfigcredstore File "site-packages/dockerpycreds/store.py", line 35, in get File "site-packages/dockerpycreds/store.py", line 93, in _execute dockerpycreds.errors.StoreError: Credentials store docker-credential-gcloud exited with "".

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "bin/docker-compose", line 6, in File "compose/cli/main.py", line 71, in main File "compose/cli/main.py", line 127, in performcommand File "compose/cli/main.py", line 287, in build File "compose/project.py", line 386, in build File "compose/project.py", line 368, in buildservice File "compose/service.py", line 1084, in build File "site-packages/docker/api/build.py", line 260, in build File "site-packages/docker/api/build.py", line 307, in _setauthheaders File "site-packages/docker/auth.py", line 310, in getallcredentials File "site-packages/docker/auth.py", line 281, in _resolveauthconfigcredstore docker.errors.DockerException: Credentials store error: StoreError('Credentials store docker-credential-gcloud exited with "".',)

This is a slightly odd scenario, but if you get this error, the fix is to edit

~/.docker/config.json

and then change everything that says "gcloud" to "gcr"

{
    "auths": {},
    "credHelpers": {
        "gcr.io": "gcr",
        "us.gcr.io": "gcr",
        "eu.gcr.io": "gcr",
        "asia.gcr.io": "gcr",
        "staging-k8s.gcr.io": "gcr",
        "marketplace.gcr.io": "gcr"
    }
}

You can replace gcloud -> gcr with the command below.

be careful, make sure this is your exact scenario before running this!

sed -i -e 's/gcloud/gcr/g' ~/.docker/config.json

Contact: Please feel free to email me at [email protected] or tweet @shekkery.
Friendly Request: Writing quality articles is hard. Getting traffic is even harder. Thank you for sharing!

Like Software Engineering, Machine Learning or Meta-Learning? Get new posts before they're released. No spam ever, promise.
Subscribe