Dale Alleshouse
Dale Alleshouse

Reputation: 1627

Unable to Push to Google Container Registry (unable to access the repository)

Whenever I attempt to push a container to the Google Container Registry from my local machine, I get the following error:

denied: Unable to access the repository; please check that you have permission to access it.

If I open the Cloud Shell, I can push containers with no problems. I have tried doing "gcloud auth login" several times and it seems to make no difference. I don't have any problems running other gcloud commands locally. Any help would be greatly appreciated.

Upvotes: 9

Views: 8347

Answers (6)

zackify
zackify

Reputation: 5434

I had this same problem, nothing solved it until I completely removed the folders listed under gcloud info (the install and config directories) then reinstalled the sdk.

Then ran gcloud components install docker-credential-gcr and set that back up. Everything worked.

Upvotes: 1

Err0r500
Err0r500

Reputation: 25

I had the same problem while trying to use GCP on a personal projet :

A look at the activity tab in GCP console showed me that I was trying to push with my professional email address (not allowed on the project) even if I just logged in with my personal one using :

gcloud auth login 

The reason was that I also ran a few months ago this command :

gcloud auth application-default login

with my professional email address.

I just had to run it again, log in with my personal address and everything worked fine !

Upvotes: 0

Dr. Max Völkel
Dr. Max Völkel

Reputation: 1859

Just to give an updated answer: I wanted to push to eu.gcr.io. Therefore, I need to authenticate to that registry (took me a while to figure that out).

So first:

docker login -e [email protected] -u oauth2accesstoken -p "$(gcloud auth print-access-token)" https://eu.gcr.io

Second:

 gcloud docker -- push eu.gcr.io/myProjectName/myComputeMachineName

Using cygwin on windows 10 pro (on Hyper-V) and these versions:

$ gcloud --version
Google Cloud SDK 148.0.0
bq 2.0.24
bq-nix 2.0.24
core 2017.03.17
core-nix 2017.02.28
gcloud
gcloud-deps 2017.02.28
gcloud-deps-linux-x86_64 2017.02.28
gsutil 4.23
gsutil-nix 4.22

and

$ docker --version
Docker version 17.03.1-ce-rc1, build 3476dbf

Upvotes: 0

jsand
jsand

Reputation: 595

FYI for other customers running into similar issues: https://github.com/docker/docker/issues/22910

There exists a bug with current versions of the Docker client (1.11, 1.12), and the default credential stores which are being enabled on new installations, which break private registries. Removing the

"credsStore": "whatever"

field from your docker config (e.g. ~/.docker/config.json) and running

gcloud docker ...

should fix the issue.

Update:

Alternately, we've implemented a credential helper of our own which solves the problem for our customers (i.e. doesn't get tripped up by the lack of a scheme in the GCR URLs that the Docker client uses to request credentials). To install the credential helper:

  • Download the helper binary and put it on your PATH
  • Execute docker-credential-gcr configure-docker to configure to the Docker client

Upvotes: 6

Lizhu Qi
Lizhu Qi

Reputation: 207

Have you run gcloud auth login?

Upvotes: 2

k4leung4
k4leung4

Reputation: 261

This sounds like gcloud might not know which project to associate you as.

You can run

gcloud info

to verify which project gcloud is using.

If it doesn't list the project that you are pushing the image under, you can specify it with the --project flag like

gcloud --project= docker push ...

To set the default project for gcloud, you can run

gcloud config set project

Upvotes: 1

Related Questions