<p>I have problem with running docker in kubernetes runner.
I've installed kubernetes runner with helm and set privileged mode to true</p>
<pre><code>runners:
  config: |
    [[runners]]
      [runners.kubernetes]
        namespace = &quot;{{.Release.Namespace}}&quot;
        image = &quot;ubuntu:20.04&quot;
        privileged = true
        allow_privilege_escalation = true 
</code></pre>
<p>I've created simple <code>.gitlab-ci.yaml</code> for test</p>
<pre><code>stages:
  - docker_test

services:
  - docker:dind

docker_test:
  stage: docker_test
  image: docker:latest
  variables:
      DOCKER_HOST: &quot;tcp://docker:2375&quot;
  script:
  - docker version
</code></pre>
<p>But when I fire this pipeline I'm gettint error</p>
<pre><code>Running with gitlab-runner 14.6.0 (5316d4ac)
  on gitlab-runner-gitlab-runner-5cc654bdf7-gjfvm augRojS5
Preparing the &quot;kubernetes&quot; executor
00:00
Using Kubernetes namespace: gitlab-runner
Using Kubernetes executor with image docker:latest ...
Using attach strategy to execute scripts...
Preparing environment
00:06
Waiting for pod gitlab-runner/runner-augrojs5-project-30333904-concurrent-0k66kk to be running, status is Pending
Waiting for pod gitlab-runner/runner-augrojs5-project-30333904-concurrent-0k66kk to be running, status is Pending
    ContainersNotReady: &quot;containers with unready status: [build helper svc-0]&quot;
    ContainersNotReady: &quot;containers with unready status: [build helper svc-0]&quot;
Running on runner-augrojs5-project-30333904-concurrent-0k66kk via gitlab-runner-gitlab-runner-5cc654bdf7-gjfvm...
Getting source from Git repository
00:03
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/gurita/gurita-core/.git/
Created fresh repository.
Checking out fe720f2f as main...
Skipping Git submodules setup
Executing &quot;step_script&quot; stage of the job script
00:00
$ docker version
Client:
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.16.12
 Git commit:        e91ed57
 Built:             Mon Dec 13 11:40:57 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: command terminated with exit code 1
</code></pre>
<p>I tried to set without variable but at this case there is no /var/run/docker.sock.</p>

<p>You need to mount the host's docker socket:</p>
<pre><code>[runners.kubernetes]
  image = &quot;ubuntu:18.04&quot;
  privileged=true
  [[runners.kubernetes.volumes.host_path]]
    name = &quot;docker-socket&quot;
    mount_path = &quot;/var/run/docker.sock&quot;
    read_only = false
    host_path = &quot;/var/run/docker.sock&quot;
</code></pre>
<p>(NOTE: This is from one of my old gitlab installations, I haven't tested this against the latest release)</p>
<p>Here's my full Runner block. You can swapping my config in for yours (make a backup of your old config first) and see if it works. Obviously change things as needed -- for example I use a specific node pool, hence the <code>node_selector</code> and <code>node_tolerations</code> sections</p>
<pre><code>## Installation &amp; configuration of gitlab/gitlab-runner
## See requirements.yaml for current version
gitlab-runner:
  install: true
  rbac:
    create: true
  runners:
    locked: false
    privileged: true
    cache:
      secretName: google-application-credentials
    config: |
      [[runners]]
        [runners.feature_flags]
          FF_GITLAB_REGISTRY_HELPER_IMAGE = true
          FF_SKIP_DOCKER_MACHINE_PROVISION_ON_CREATION_FAILURE = true
        [runners.kubernetes]
          image = &quot;ubuntu:18.04&quot;
          privileged=true
          [[runners.kubernetes.volumes.host_path]]
            name = &quot;docker-socket&quot;
            mount_path = &quot;/var/run/docker.sock&quot;
            read_only = false
            host_path = &quot;/var/run/docker.sock&quot;
          [runners.kubernetes.node_selector]
            &quot;cloud.google.com/gke-nodepool&quot; = &quot;gitlab-runners&quot;
          [runners.kubernetes.node_tolerations]
            &quot;appName=gitlab&quot; = &quot;NoExecute&quot;
        {{- if .Values.global.minio.enabled }}
        [runners.cache]
          Type = &quot;gcs&quot;
          Path = &quot;gitlab-runner&quot;
          Shared = true
          [runners.cache.gcs]
            BucketName = &quot;runner-cache&quot;
        {{ end }}
  podAnnotations:
    gitlab.com/prometheus_scrape: &quot;true&quot;
    gitlab.com/prometheus_port: 9252

</code></pre>
