docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
@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)
Any thoughts as where I am messing it up.
Thanks !!
This thread saved my sanity and mental health.
My case was the following.
I am maintaining a repository with common CI/CD assets like jobs shared across other projects and custom images for job runners.
I created a custom image for one of my runners (pre-built with some dependencies).
The image happily pulls locally with no credentials, but It simply failed to pull in a CI/CD context with the following message in the runner’s log:
“ERROR: Job failed: failed to pull image “registry.gitlab.com/redacted-group/redacted-sub-group/redacted-project/sonar-scanner-runner:latest” with specified policies [always]: Error response from daemon: pull access denied for registry.gitlab.com/redacted-group/redacted-sub-group/redacted-project/sonar-scanner-runner:latest repository does not exist or may require ‘docker login’: denied: requested access to the resource is denied (manager.go:237:0s)”
I finally solved this issue at the repository where I pushed the sonar-scanner-runner:latest image.
Go to “Settings” → “CI/CD” → Token Access
In the Token Access section, “Limit access to this project” should be switched on by default as a security measure.
If true, just include all the projects allowed to access the project.
Include all groups and subgroups like this:
parent-group/some-sub-group/a-project-with-access
That’s it.
Many thanks to Oleksiy for helping me out with this.
I tried to solve this with ChatGPT, Bard, Claude, and prayers to the eternal Force with a zero result for over 3 hours.
Finally - I settled with the old good way - Googling and digging into forums.
This is a highly kind reminder that a skilled developer is worth 100 more than any LLM.
@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