abb
abb

Reputation: 382

Unable to run gcloud docker push from google compute engine instance

When I do gcloud docker push i get the following error.

denied: Unable to create the repository, please check that you have access to do so.

gcloud info shows correct project name as configured in gcloud.

Can somebody please guide me with this issue? Or suggest an alternative.

I have tried directly logging in without gcloud, login succeeds but push fails

$docker login -e [email protected] -u oauth2accesstoken  -p "$(gcloud auth print-access-token)" https://gcr.io
Flag --email has been deprecated, will be removed in 1.14.
Login Succeeded
$ docker push gcr.io/project/imagename
...
denied: Unable to create the repository, please check that you have access to do so.

$ gcloud --version Google Cloud SDK 147.0.0

$ docker --version Docker version 17.03.0-ce, build 3a232c8

Upvotes: 2

Views: 3308

Answers (2)

Henkie85
Henkie85

Reputation: 245

I know this is an old post. But I couldn't find a good answer when I came here. gcloud docker -- push is deprecated for Docker clients above 18.03.

You need to use the normal Docker push commands. But before you do first execute the following command. This will configure Docker to use gcloud as an credential helper.

gcloud auth configure-docker

You will also see that some URL will be added to a config

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

After that, you can do a normal docker push and your image will be added to your repo

docker push gcr.io/<project-id/<image>:<tag>

Upvotes: 1

Nghia Tran
Nghia Tran

Reputation: 61

If you do

gcloud docker -- push gcr.io/X/Y

you will need to have permission to write to the GCP named 'X'. Typically you will need to be added to that project as a project EDITOR.

In this case GCR does not complain about the project shown by 'gcloud info'.

Upvotes: 6

Related Questions