Search code examples
dockergoogle-cloud-platformvirtual-machinegoogle-container-registrygoogle-container-os

how to assign "container registry" permissions to virtual machine in Google Cloud


I'm creating a virtual machine in Google Cloud with full access scopes enter image description here

When I connect to the virtual machine by SSH and try to pull a docker image from Container registry, it throws permissions error:

enter image description here

So I wonder how do I give permissions for my Container registry

I thought giving full access to API would solve this problem, but it doesn't

By the way I know I can directly put image from container registry to compute engine, but this is not what I want, it's not gonna be only one image I'll be running, it's gonna be some of them


Solution

  • Permissions for Container Registry are controlled by Cloud Storage IAM. Container Registry stores container images in a Cloud Storage bucket in your project.

    To authorize docker to use Google credentials there are several methods. I use this method:

    gcloud auth configure-docker
    

    However, that method is no longer recommended. This method is recommended:

    gcloud components install docker-credential-gcr
    docker-credential-gcr configure-docker
    

    Container Registry Authentication Methods