Cannot connect to the Docker daemon - Gitlab runner on Kubernetes
My issue is similar to gitlab-org/gitlab-foss#34419 (closed) but I'm creating a new one because
- The original issue is closed.
- None of the suggested answers is working for me.
- Issue template in gitlab-foss is pointing to this repository.
I'm running a Gitlab server v12.5.3-ee on a Kubernetes cluster v1.15.6. The Gitlab server (and runner) has been built using the official Gitlab Helm chart with the following values:
certmanager:
install: false
certmanager-issuer:
email: ####
gitlab-runner:
runners:
privileged: true
global:
email:
display_name: ####
from: ####
reply_to: ####
hosts:
domain: ####
https: false
ingress:
annotations:
kubernetes:
io/tls-acme: true
tls:
enabled: false
smtp:
address: smtp.gmail.com
authentication: login
enabled: true
openssl_verify_mode: peer
password:
secret: smtp-gmail
port: 587
starttls_auto: true
user_name: ####
AutoDevOps pipelines are working but I'm not able to have custom ci/cd working with .gitlab-ci.yml
file.
this is my .gitlab-ci.yml
:
image: docker:git
services:
- docker:18.09.7-dind
variables:
DOCKER_DRIVER: overlay
before_script:
- docker info
build:
script:
- echo 'this is the script'
- docker build -t frontend .
- docker run -v ${PWD}:/app -v /app/node_modules -p 4200:4200 --rm frontend
- docker tag frontend registry.gitlab.com:5000/frontend
- docker push registry.gitlab.com:5000/frontend
What I already tried:
- Replace
docker:git
image bydocker:latest
- Using
19.03.0-dind
image - Adding
DOCKER_HOST: tcp://localhost:2375
variable
When installing Gitlab with Helm chart I've been passing the gitlab-runner.runners.privileged=true
as we can see in my Helm chart values.
I assume my runner is in privileged mode because at first it wasn't and AutoDevOps was facing the same error but after enabling it via Helm chart the AutoDevOps started to work.
However what seems a bit strange is that if I run kubectl describe configmap gitlab-gitlab-runner -n gitlab
on my cluster, the config.toml
is not showing the privileged attribute:
config.toml:
----
concurrent = 10
check_interval = 30
log_level = "info"
listen_address = '[::]:9252'
However I'm not sure how Helm chart assign the privileged
attribute. I'm also not able to access the config.toml
file inside the container by doing an exec as the owner of the file is "root".
Am I missing something on how to use custom CI/CD on a Kubernetes runner ?
Thanks.