I use the GitLab.com free plan to host certain projects for my clients in separate namespaces.
I have some base Docker images hosted in a private repository’s container registry in GitLab. I reference this image from other projects in other namespaces. Furthermore, I’m the sole developer in those namespaces, so It’s clear I have access rights to these docker images on that other repository.
Now, for some reason, I see an error in one project when it tries to pull the docker image:
Failed to pull image with policy "always": Error response from daemon: pull access denied for registry.gitlab.com/<url-to-image>, repository does not exist or may require 'docker login': denied: requested access to the resource is denied (manager.go:203:0s)
This didn’t happen 10 days ago, but happens now. For no particular reason. There was no change regarding the CI setup. And it only seems to happen in that one project. I use it exactly in the same way as 10 days ago, when it worked.
I already tried switching to a different Docker image published in the same container registry as the one failing. But this fails too.
So, the main questions now are
Were there any significant GitLab CI changes since May 23 that might cause this?
Is there any limitation how often a project can pull images from the container registry in GitLab?
Are there any other limitations I might need to know of that could cause the issue?
I have the same user permissions in all projects, in the ones where it still works and the single one, where it doesn’t. I can also pull the image locally.
The only workaround I found was to set the project to public, while restricting all access to the features except the container registry to members only. I found no real solution.
Facing the same problem without the possibility to make the project public, I took the following approach:
Create a deploy key with “read registry” permission in the repo for the “source” image
Pull this image in the pipeline of your target repo (docker login/docker pull/docker logout) using the deploy key created above
Now you have this image available locally in your build environment and can access it.
In my case I needed the Docker image located in source repo’s registry as the base image for my Dockerfile in the target repo. The code in the target repo’s pipeline looks basically like this:
Same issue here. As mentioned by @renestalder I also had to set the source repo with the docker image Public and restrict access to the features Only Project Members. See following screenshot:
I solved the problem in Gitlab.com 16.2 via allowing access to my second project CI_JOB_TOKEN
this can be done in your base project in Settings > CI/CD > Token Access
you will need to add full notion of you “client” project, i.e. GROUP/SUBGROUP/PROJECT_NAME
after that in client project use docker login via token
@oleksiy I am also using 16.2. I am not able to make it work. Here are my steps -
Say I have a group/Project where I am maintaining all my images. I used manage and granted access to the other group ( say group B) where I need to access the images. It is giving me errors. However the project ( where I am hosting the images) is showing in shared projects list ( from group B)
@mkind solution works in 16.9 – create a deploy token for the project containing your image.
If you’re trying to reference a pushed image from projects in a group using the Docker executor and an image: entry in .gitlab-ci.yml, put the deploy token into a group variable MY_PROJECT_TOKEN and reference it from another group variable DOCKER_AUTH_CONFIG
/group/target/.gitlab-ci.yml contains:
default:
# Set GitLab group variables
#
# DOCKER_AUTH_CONFIG (expanded group variable)
# {"auths":{"gitlab.example.com:5050":{"auth":"$MY_PROJECT_TOKEN"}}}
#
# MY_PROJECT_TOKEN (masked group variable)
# Read-registry permission in project deploy token for /namespace/project
# EXPIRES after one year.
# Base64 encoding of username:token
#
# https://docs.gitlab.com/ee/user/project/deploy_tokens/
# https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#access-an-image-from-a-private-container-registry
image: gitlab.example.com:5050/namespace/project/my-image