Search code examples
dockergitlabgitlab-cinexusgitlab-ci-runner

Gitlab Runner can't use docker image from Nexus registry


So i have an Gitlab instanz, a Gitlab runner and a nexus server.
Because we are currently using an standalone registry from an Github project we want to switch to nexus for the docker registry aswell. Everything works fine except for the docker image the runner itself is using.
Below are the two different ways getting the docker image for the Gitlab runner:

image: jenkins.intern.de/pipeline-env:latest
# image: nexus.intern.de/docker-group/test/pipeline-env:latest

The first one is working fine but the second one keeps failing with the following error:

Running with gitlab-runner 16.3.0 (8ec04662)
  on debian U7maLHgP, system ID: s_bb2cc94b24c5
Preparing the "docker" executor
00:01
Using Docker executor with image nexus.intern.de/docker-group/test/pipeline-env:latest ...
Pulling docker image nexus.intern.de/v2/docker-group/test/pipeline-env:latest ...
WARNING: Failed to pull image with policy "always": Error response from daemon: Head "https://nexus.intern.de/v2/docker-group/test/pipeline-env/manifests/latest": no basic auth credentials (manager.go:237:0s)
ERROR: Job failed: failed to pull image "nexus.intern.de/docker-group/test/pipeline-env:latest" with specified policies [always]: Error response from daemon: Head "https://nexus.intern.de/v2/docker-group/test/pipeline-env/manifests/latest": no basic auth credentials (manager.go:237:0s)

The gitlab runner i running locally on my workstation. When i use the docker commands locally on my workstation everything is fine i can do docker login, docker pull, docker push without any problems.

The Nexus server is giving me the following url to pull and push images to the registry: https://nexus.intern.de/repository/docker-group/ and i'm also tried putting the name repository inside the url which fails with the same error. So I'm a bit at loss where to look at for solving this.

Is there any way i can see if the problem is on the gitlab or nexus configuration. There might be something im missing out. Any ideas are highly appreciated!


Solution

  • This is solved by providing the DOCKER_AUTH_CONFIG variable via the Gitlab Instance.

    Thanks to @KamilCuk for pointing to the correct document: https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#use-statically-defined-credentials