Adam Malik commented on issue #490 at GitLab.org / charts / GitLab Runner

Adam Malik
2024-08-27T14:48:36Z

Based on this issue gitlab-org/gitlab-runner#27215 (closed) you will find a working solution. The key is using the healthcheck on docker-in-docker, it waits until the service is actually ready before using it. I encountered this on new nodes in the cluster which randomly failed.

Here is an example using the Kubernetes executor without tls:

Runner config:

config: |
[[runners]]
name = "whatever"
url = "{{ .Values.gitlabUrl }}"
executor = "kubernetes"
[runners.kubernetes]
namespace = "{{.Release.Namespace}}"
image = "docker:24.0.5"
privileged = true

Pipeline variables:

variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""

Build job:

build-docker:
image: docker:24.0.5
stage: build
services:
- name: docker:24.0.5-dind
command: [ "--tls=false" ]
variables:
HEALTHCHECK_TCP_PORT: "2375"
script:
- docker build -t whatever .