Runner can't use local docker images

Hello Forum,

I’m facing an issue that I think you are already aware. Just installed the latest GitLab server and runner on the same computer (This will change with time) and I just can’t use pre-created and locally existing docker images for building. It always failes with saying it couldn’t download the image from docker hug. Ofcorse it couldn’t, it is my own image made by me. It is not on DockerHub and I’m not planing to upload it yet. Do you know any sollution for this issue? How can I stop GitLab to keep fetching the images from online? In my config.toml I have only 2 runners section and that’s all. :confused:

Cheers in advance!

You are aware you’re fighting the system (runner on same machine is bad for anything but a demo).

According to the docs: If you can see the image in the docker images command on the server (which is also your runner), it should work as an image.

If your docker image is the same name as a docker-hub image, perhaps the runner is programmed to prefer the docker-hub image for some technical reasons or for the purpose of updating the ci server from docker-hub. Again, it seems like you’re going against the grain here.

I’m aware that runner is not supposed to be on the same machine, I forgot to mention this is only a pure demo, indeed.

I can see the images if I ask docker about the downloaded images, however, I still get the build error saying:
> Running with gitlab-ci-multi-runner 1.8.1 (a2eXXXX)

Using Docker executor with image alpine-nginx-fpm-node ...
Pulling docker image mysql:latest ...
Starting service mysql:latest ...
Waiting for services to be up and running...
Using locally found image version with exactly the same ID
Pulling docker image alpine-nginx-fpm-node ...
ERROR: Build failed: Error: image library/alpine-nginx-fpm-node:latest not found

And for docker images command:

[root@gitlab]# docker images

alpine-nginx-fpm-node latest ef47XXXXcda3 14 hours ago 109.2 MB
gitlab-runner-prebuilt-x86_64 a2efdd4 93beXXXXX729 18 hours ago 37.93 MB
mysql latest 594XXXXX8de 6 days ago 400.1 MB
alpine latest baaXXXXXX1ea 8 weeks ago 4.799 MB

The install of GitLab was made according to the online documentations and I haven’t changed the smallest bit. This error came out from the start. I’m still waiting for a way how to tell GitLab to use the local images instead of trying to pull them from DockerHub.

Ok deleted my useless answer above. I have no idea what’s going on there. Hope someone else can offer some ideas.

You should set pull_policy = "if-not-present" in your /etc/gitlab-runner/config.toml. By default, the runner always tries to pull the image from DockerHub.

1 Like

I have the same problem, although under different circumstances.

I’m have build that fails some specs that are green on my local machine. Now I want to reproduce the CI run on my machine, so I installed the gitlab-runner binary (version is 9.5.0) in my home dir and try to run it:

~/bin/gitlab-runner exec docker test --docker-image=base-image:latest

It still tries to pull base-image:latest, which is local to my machine. I added the following ~/.gitlab-runner/config.toml, but it doesn’t seem to be read at all:

log_level = "warning"
pull_policy = "if-not-present"

Maybe exec docker does’t read any config files?

I had the same issue as @AndreasSliwka, no matter what option I put into pull_policy in the config file, it would always try to pull the image. In then end I added --docker-pull-policy=never to the gitlab-runner call and that finally took it.

gitlab-runner exec docker --docker-pull-policy=never test

I’m running:

Version:      10.1.0
Git revision: c1ecf97f
Git branch:   10-1-stable
GO version:   go1.8.3
Built:        Sat, 21 Oct 2017 21:33:58 +0000
OS/Arch:      darwin/amd64

in the config.toml file, under the docker settings, add: pull_policy = “never”

1 Like
pull_policy = "if-not-present"

Works for me

Using Docker executor with image docker_myty-php71-dev ...
Using locally found image version due to if-not-present pull policy