<p>I have configured gitlab runner within kubernetes , which is not able to connect to docker daemon . Showing below error .</p>

<blockquote>
  <p>$ docker build --cache-from "${DOCKER_IMAGE_TAG}" -t
  "${DOCKER_IMAGE_TAG}" .</p>
  
  <p>Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is
  the docker daemon running? ERROR: Job failed: command terminated with
  exit code 1</p>
</blockquote>

<pre><code>stages:
  - push_to_docker

docker_image:
 image: 'docker:latest'
 services:
  - docker:dind
 stage: push_to_docker
 variables:
    DOCKER_IMAGE_TAG: 'gcr.io/abcd-project/test'
 script:
   - docker build --cache-from "${DOCKER_IMAGE_TAG}" -t "${DOCKER_IMAGE_TAG}" .
   - echo "$SERVICE_ACCOUNT_KEY" &gt; key.json
   - docker login -u _json_key --password-stdin https://gcr.io &lt; key.json
   - docker push ${DOCKER_IMAGE_TAG}
 only:
   - master
 tags:
   - abcd
</code></pre>

<p>My <strong>config.toml</strong> file is as below </p>

<pre><code>listen_address = "[::]:9252"
concurrent = 4
check_interval = 3
log_level = "info"

[session_server]
  session_timeout = 1800

[[runners]]
  name = "runner-gitlab-runner-78c7db94bc-lzv76"
  request_concurrency = 1
  url = "https://gitlab.com/"
  token = "*********"
  executor = "kubernetes"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
  [runners.kubernetes]
    host = ""
    bearer_token_overwrite_allowed = false
    image = "ubuntu:16.04"
    namespace = "gitlab-managed-apps"
    namespace_overwrite_allowed = ""
    privileged = true
    service_account_overwrite_allowed = ""
    pod_annotations_overwrite_allowed = ""
    [runners.kubernetes.pod_security_context]
    [runners.kubernetes.volumes]
</code></pre>

<p>Checked with configuration as below</p>

<pre><code>    image: docker:19.03.1
    services:
    - docker:19.03.1-dind
    variables:
      DOCKER_HOST: tcp://docker:2375
</code></pre>

<p>And my .gitlab-ci.yml file after changing the configuration is as below:</p>

<pre><code>stages:
  - push_to_docker
  - deploy_into_kubernetes
variables:
  DOCKER_IMAGE_TAG: 'gcr.io/abcd-project/test:$CI_COMMIT_SHORT_SHA'
  DOCKER_HOST: tcp://docker:2375

docker_image_creation:
 image: docker:19.03.1
 services:
  - docker:19.03.1-dind

 stage: push_to_docker

 script:
   - docker build -t "${DOCKER_IMAGE_TAG}" .
   - echo "$SERVICE_ACCOUNT_KEY" &gt; key.json
   - docker login -u _json_key --password-stdin https://gcr.io &lt; key.json
   - docker push ${DOCKER_IMAGE_TAG}
 tags:
   - cluster
   - kubernetes
</code></pre>

<p>but getting bellow error :</p>

<blockquote>
  <p>Skipping Git submodules setup $ docker build -t "${DOCKER_IMAGE_TAG}"
  . time="2019-11-04T08:07:37Z" level=error msg="failed to dial gRPC:
  cannot connect to the Docker daemon. Is 'docker daemon' running on
  this host?: dial tcp: lookup docker on 10.0.0.10:53: no such host"
  error during connect: Post
  <a href="http://docker:2375/v1.40/build?buildargs=%7B%7D&amp;cachefrom=%5B%5D&amp;cgroupparent=&amp;cpuperiod=0&amp;cpuquota=0&amp;cpusetcpus=&amp;cpusetmems=&amp;cpushares=0&amp;dockerfile=Dockerfile&amp;labels=%7B%7D&amp;memory=0&amp;memswap=0&amp;networkmode=default&amp;rm=1&amp;session=l1ce41pzm1p9a4jdhs31z9p64&amp;shmsize=0&amp;t=gcr.io%2Fupbeat-flame-247110%2Fgitlab-runner-poc%3A25b1faa0&amp;target=&amp;ulimits=null&amp;version=1" rel="nofollow noreferrer">http://docker:2375/v1.40/build?buildargs=%7B%7D&amp;cachefrom=%5B%5D&amp;cgroupparent=&amp;cpuperiod=0&amp;cpuquota=0&amp;cpusetcpus=&amp;cpusetmems=&amp;cpushares=0&amp;dockerfile=Dockerfile&amp;labels=%7B%7D&amp;memory=0&amp;memswap=0&amp;networkmode=default&amp;rm=1&amp;session=l1ce41pzm1p9a4jdhs31z9p64&amp;shmsize=0&amp;t=gcr.io%2Fupbeat-flame-247110%2Fgitlab-runner-poc%3A25b1faa0&amp;target=&amp;ulimits=null&amp;version=1</a>: context canceled</p>
</blockquote>

Satwik Mukherjee
<p>use docker19, which automatically configures its host for you:</p>

<pre><code>image: docker:19.03.1
services:
- docker:19.03.1-dind
variables:
  DOCKER_HOST: tcp://docker:2375
</code></pre>

<p><a href="https://docs.gitlab.com/ee/ci/docker/using_docker_build.html" rel="noreferrer">https://docs.gitlab.com/ee/ci/docker/using_docker_build.html</a></p>
