How to push container to Google Container Registry

2019-05-15 17:53发布

问题:

EDIT: I'm just going to blame this on platform inconsistencies. I have given up on pushing to the Google Cloud Container Registry for now, and have created an Ubuntu VM where I'm doing it instead. I have voted to close this question as well, for the reasons stated previously, and also as this should probably have been asked on Server Fault in the first place. Thanks for everyone's help!

running $ gcloud docker push gcr.io/kubernetes-test-1367/myapp results in:

The push refers to a repository [gcr.io/kubernetes-test-1367/myapp]
595e622f9b8f: Preparing
219bf89d98c1: Preparing
53cad0e0f952: Preparing
765e7b2efe23: Preparing
5f2f91b41de9: Preparing
ec0200a19d76: Preparing
338cb8e0e9ed: Preparing
d1c800db26c7: Preparing
42755cf4ee95: Preparing
ec0200a19d76: Waiting
338cb8e0e9ed: Waiting
d1c800db26c7: Waiting
42755cf4ee95: Waiting
denied: Unable to create the repository, please check that you have access to do so.

$ gcloud init results in:

Welcome! This command will take you through the configuration of gcloud.

Settings from your current configuration [default] are:
[core]
account = <my_email>@gmail.com
disable_usage_reporting = True
project = kubernetes-test-1367
Your active configuration is: [default]

Note: this is a duplicate of Kubernetes: Unable to create repository, but I tried his solution and it did not help me. I've tried appending :v1, /v1, and using us.gcr.io

Edit: Additional Info

$ gcloud --version
Google Cloud SDK 116.0.0

bq 2.0.24
bq-win 2.0.18
core 2016.06.24
core-win 2016.02.05
gcloud
gsutil 4.19
gsutil-win 4.16
kubectl
kubectl-windows-x86_64 1.2.4
windows-ssh-tools 2016.05.13

+

$ gcloud components update

All components are up to date.

+

$ docker -v
Docker version 1.12.0-rc3, build 91e29e8, experimental

回答1:

What version of gcloud and Docker are you using?

Looking at your requests, it seems as though the Docker client is not attaching credentials, which would explain the access denial.

I would recommend running gcloud components update and seeing if the issue reproduces. If it still does, feel free to reach out to us on gcr-contact at google.com so we can help you debug the issue and get your issue resolved.



回答2:

I am still not able to push a docker image from my local machine, but authorizing a compute instance with my account and pushing an image from there works. If you run into this issue, I recommend creating a Compute Engine instance (for yourself), authorizing an account with gcloud auth that can push containers, and pushing from there. I have my source code in a Git repository that I can just pull from to get the code.



回答3:

The first image push requires admin rights for the project. I had the same problem trying to push a fresh container to GCR for a team project.

You might also want to have a look at docker-credential-gcr. Hope that helps.



回答4:

Thanks for adding your Docker version info. Does downgrading Docker to a more stable release (e.g. 1.11.2) help at all? Have you run 'docker-machine upgrade'?



回答5:

It seems like you're trying to run gcloud docker push from an Google Compute Engine instance without a proper security scope of read/write access to Google Cloud Storage (it's where Google Container Registry stores the images of your containers behind the scene).

Try to create another instance, but this time with proper access scopes, i.e.:

gcloud compute --project "kubernetes-test-1367" instances create "test" --zone "us-east1-b" --machine-type "n1-standard-1" --network "default" --scopes default="https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring.write","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management","https://www.googleapis.com/auth/devstorage.full_control" --image "/debian-cloud/debian-8-jessie-v20160629" --boot-disk-size "10" --boot-disk-type "pd-standard" --boot-disk-device-name "test-1"

Once you create new instance, ssh into it and then try to re-run the gcloud docker push gcr.io/kubernetes-test-1367/myapp command



回答6:

I checked for

gcloud auth list

to see my application is the active account and not my personal Google account. After setting

gcloud config set account example@gmail.com

I was able to push

gcloud docker -- push eu.gcr.io/$PROJECT_ID/my-docker:v1

So I can continue http://kubernetes.io/docs/hellonode/



回答7:

I had a similar issue and it turned out that I had to enable billing for the project. When you have a new Google Cloud account you can enable only so many projects with billing. Once I did that it worked.



回答8:

Also this could be the cause of this problem (was in my case):

Important: make sure the Compute Engine API is enabled for your project on the

Source: https://pinrojas.com/2016/09/12/your-personal-kubernetes-image-repo-in-a-few-steps-gcr-io/