I have private project group on GitLab.
I store all the images on its container registry.
Can another project in the same group, using that registry as the base image on GitLab CI job?
Hi @altianogerung, good question!
Can another project in the same group, using that registry as the base image on GitLab CI job?
Yes, you can absolutely use your Private GitLab Container Registry as the source for base image in CI job.
To do so, you’ll need to define the image:
in your CI job to use your local registry (eg. image: registry.gitlab.com/greg/docker/docker:stable
instead of image: docker:stable
)
As its a private registry, you’ll also need pass the credentials to authenticate before you can docker pull
the image. There are several ways to do this outlined here:
1 Like
go to private project settings > CI/CD > Token Access,
you can
- turn off “Limit access to this project”, and allow all other projects to access this project.
- add custom project to allowlist.
1 Like
I get this error:
Running with gitlab-runner 17.4.0~pre.110.g27400594 (27400594)
on blue-3.saas-linux-small-amd64.runners-manager.gitlab.com/default zxwgkjAP, system ID: s_d5d3abbdfd0a
Preparing the "docker+machine" executor 00:32
Using Docker executor with image registry.gitlab.com/newbie/test:latest ...
Starting service docker:dind...
Pulling docker image docker:dind ...
Using docker image sha256:8314b971e611487bd98e2907c84df89c10243359ecf1452511dfa5cf594659fd for docker:dind with digest docker@sha256:b0c1179ea32ad77bdb7b852b037e54b11022304c2f2662af1954ef53869314b2 ...
Waiting for services to be up and running (timeout 30 seconds)...
Authenticating with credentials from job payload (GitLab Registry)
Pulling docker image registry.gitlab.com/newbie/test:latest ...
WARNING: Failed to pull image with policy "always": Error response from daemon: pull access denied for registry.gitlab.com/newbie/test, repository does not exist or may require 'docker login': denied: requested access to the resource is denied (manager.go:251:0s)
ERROR: Job failed: failed to pull image "registry.gitlab.com/newbie/test:latest" with specified policies [always]: Error response from daemon: pull access denied for registry.gitlab.com/newbie/test, repository does not exist or may require 'docker login': denied: requested access to the resource is denied (manager.go:251:0s)
CI/CD Variables:
- CI_REGISTRY
- CI_REGISTRY_PASSWORD
- CI_REGISTRY_USER
Can someone help me?
Can someone provide me a sample .gitlab-ci.yml?