Pushing Docker Image to GitLab Registry not working

Problem to solve

I setup a Self-hosted GitLab Community edition on docker, and I’m trying to run an auto deploy CI pipeline to create a simple docker container and push it to the registry.

I setup the GitLab-runner and everything but not it is still failing on uploading the image to the container registry and I have no idea how to troubleshoot further.

My pipeline is below, which I just added to dump the environment variables. The variable dump contains the CI_REGISTRY and it is set to the correct domain. Also CI_REGISTRY_USER is set as well as CI_DEPLOY_USER='gitlab+deploy-token-1'.

The pipeline at first even prints that the login was successful:

Logging in to GitLab Container Registry with CI credentials...
Login Succeeded
Logging in to GitLab Dependency proxy with CI credentials...
Login Succeeded

But further down in the build, the errors start:

#6 importing cache manifest from xxxx:latest
#6 ...
#7 importing cache manifest from xxxx:b043fcb4039672a66458e2672401888a0ddc0eea
#7 ERROR: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
#6 importing cache manifest from xxxx:latest
#6 ERROR: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
#13 ERROR: denied: requested access to the resource is denied

Container Registry feature is enabled in the project as well as on the server. It is visible on the menu.

The Dockerfile is also as simple as it gets:

FROM python:3

WORKDIR /usr/src/app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

CMD [ "python", "./main.py" ]

Steps to reproduce

Try to push an image from a self-hosted runner to a self-hosted GitLab Instance with the default configuration. All running on docker.

Configuration

variables:
  TEST_DISABLED: "true"

include:
  - template: Auto-DevOps.gitlab-ci.yml

log_variables:
  stage: build
  script:
    - export

Versions

  • Self-managed v18.4.1
  • Self-hosted Runners (newest)