Gitlab registry images not getting pulled in Gitlab CI progcess

959 views Asked by At

I am using /kaniko/executor to build the image and push to gitlab container registry (refer below script ). Image getting created and copied to container registry.

Now I am using this base image into gitlab-ci process of different project with image tag but getting below error.

**Warning/Error log snippet : **

WARNING: Failed to pull image with policy "": image pull failed: rpc error: code = Unknown desc = failed to pull and unpack image "registry.gitlab.com/:v1.0.0": failed to resolve reference "registry.gitlab.com/:v1.0.0": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

ERROR: Job failed: prepare environment: waiting for pod running: pulling image "registry.gitlab.com/:v1.0.0": image pull failed: rpc error: code = Unknown desc = failed to pull and unpack image "registry.gitlab.com/:v1.0.0": failed to resolve reference "registry.gitlab.com/:v1.0.0": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information

.gitlab-ci.yaml file code to create image and push to container registry:

variables:
  GIT_STRATEGY: clone
  IMAGE_VERSION: v1.0.0

default:
  tags:
    - applications

stages:
  - build

build_gitlab_container:
  stage: build
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
  script:
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
    - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$IMAGE_VERSION


So far I have validated below options

  1. Incorrect repository URL : My repository is correct
  2. Authorization details
  3. Insufficient scope - I am owner of this gitlab subgroup and project.
1

There are 1 answers

0
Ajay Bhosale On

I was facing same problem for a new project.

Go to Settings > CI/CD > Token Access for the base image project, and add your target project.

enter image description here

Do remember to trim / from path.