Gitlab CI cannot retrieve image from private docker registry

I would like to create a Docker based on the Gitlab CI runner that pulls docker images for assembly from the private Docker registry (v2). I can not get Gitlab Runner to pull the image from the local registry, it is trying to get something from API /v1 . The following error message appears:

ERROR: Build error: Error retrieving image: Get http: // registry: 5000 / v1 / repositories / maven / images : type tcp: lookup registry at 127.0.1.1:53: no such host

Here is a minimal example using docker-compose and a web browser.

I have the following docker-compose.yml file:

 version: "2" services: gitlab: image: gitlab/gitlab-ce ports: - "22:22" - "8080:80" links: - registry:registry gitlab_runner: image: gitlab/gitlab-runner volumes: - /var/run/docker.sock:/var/run/docker.sock links: - registry:registry - gitlab:gitlab registry: image: registry:2 

After logging into Gitlab for the first time, I will register the runner in an instance of Gitlab:

 root@130d08732613 :/# gitlab-runner register Running in system-mode. Please enter the gitlab-ci coordinator URL (eg https://gitlab.com/ci): http://192.168.61.237:8080/ci Please enter the gitlab-ci token for this runner: tE_1RKnwkfj2HfHCcrZW Please enter the gitlab-ci description for this runner: [130d08732613]: docker Please enter the gitlab-ci tags for this runner (comma separated): Registering runner... succeeded runner=tE_1RKnw Please enter the executor: docker-ssh+machine, docker, docker-ssh, parallels, shell, ssh, virtualbox, docker+machine: docker Please enter the default Docker image (eg. ruby:2.1): maven:latest Runner registered successfully. Feel free to start it, but if it running already the config should be automatically reloaded! 

After that, I see the Gitlab runner in my Gitlab instance:

Gitlab Runner on a Gitlab instance

After that, I click a simple maven image into my newly created Docker repository:

 vilmosnagy@vnagy-del l:~/$ docker tag maven:3-jdk-7 172.19.0.2:5000/maven:3-jdk7 vilmosnagy@vnagy-dell :~/$ docker push 172.19.0.2:5000/maven:3-jdk7 The push refers to a repository [172.19.0.2:5000/maven] 79ab7e0adb89: Pushed f831784a6a81: Pushed b5fc1e09eaa7: Pushed 446c0d4b63e5: Pushed 338cb8e0e9ed: Pushed d1c800db26c7: Pushed 42755cf4ee95: Pushed 3-jdk7: digest: sha256:135e7324ccfc7a360c7641ae20719b068f257647231d037960ae5c4ead0c3771 size: 1794 

(I got the IP address 172.19.0.2 from the docker inspect )

After that, I create a test project in Gitlab and add a simple .gitlab-ci.yml :

 image: registry:5000/maven:3-jdk-7 stages: - build - test - analyze maven_build: stage: build script: - "mvn -version" 

And after the build, Gitlab gives the error seen at the beginning of the message.

If I enter the gitlab-runner working container, I can access the registry at the specified URL:

 vilmosnagy@vnagy-dell :~/$ docker exec -it comptest_gitlab_runner_1 bash root@c0c5cebcc06f :/# curl http://registry:5000/v2/maven/tags/list {"name":"maven","tags":["3-jdk7"]} root@c0c5cebcc06f :/# exit exit vilmosnagy@vnagy-dell :~/$ 

But the error is still the same:

Running gitlab in gitlab instance

Do you have an idea how to make gitlab-runner use the private registry v2 api?

+11
source share
2 answers

Newer Gitlab and Gitlab Runners support this, see: https://docs.gitlab.com/runner/configuration/advanced-configuration.html#using-a-private-container-registry

On old Gitlab, I solved this problem by copying the authorization key to ~/.docker/config.json

 { "auths": { "my.docker.registry.url": { "auth": "dmlsbW9zLm5hZ3k6VGZWNTM2WmhC" } } } 

I entered this container from my computer and copied this authorization key into the Gitlab Runner docker container.

+5
source

What version of docker are you using on gitlab? Also, for the v2 registry, you must explicitly allow the unsafe registry using the command line or protect your registry with a certificate.

Otherwise, Docker rolls back to the v1 registry if it receives a security exception.

0
source

All Articles