Search code examples
google-cloud-platformgoogle-container-registry

Multiple GCR Project Registry Login in Jenkins Machine


We have our cloud setup on GCP with multiple projects. In our Jenkins machines, I can see multiple entries of docker registries. One of them is something like this:-

"https://gcr.io/abc-defghi-212121": {
                    "auth": "somethingsomethingsomething=",
                    "email": "not@val.id"

I want to do same thing for another project which will be like:-

"https://gcr.io/jkl-mnopqr-313131": {
                    "auth": "somethingsomethingsomething=",
                    "email": "not@val.id"

So that if I do docker login to both registries it should work. I have followed below links:- https://cloud.google.com/container-registry/docs/advanced-authentication

there are different methods in this but still confused. Please help.


Solution

  • The most common authentication method to use docker with container registry is using gcloud as a Docker credential helper. This authentication method is performed by running: $ gcloud auth configure-docker

    This will create a json file, ~/.docker/config.json, that will "tell" docker to authenticate in container registry using the gcloud current user.

    However, I am assuming in your case it's Jenkins that builds and pushes your images to the container registry. You need to authenticate it, which I believe it's performed using the OAuth plugin. You can find it in the Jenkins interface: Jenkins -> Credentials -> Global Credentials -> Add Credentials

    Nevertheless, you could also refer to this documentation where explained how to troubleshoot common Container Registry and Docker issues. Also, make sure that you have the required permission to push or pull.