title: Role of docker-in-docker (dind) service in gitlab ci
body: <p>According to the official <a href="https://docs.gitlab.com/ce/ci/docker/using_docker_build.html#use-docker-in-docker-executor" rel="noreferrer">gitlab documentation</a>, one way to enable <code>docker build</code> within <code>ci</code> pipelines, is to make use of the <code>dind</code> service (in terms of <code>gitlab-ci</code> <a href="https://docs.gitlab.com/ce/ci/services/" rel="noreferrer">services</a>).</p>
  <p>However, as it is always the case with ci jobs running on docker executors, the <code>docker:latest</code> image is also needed.</p>
  <p>Could someone explain:</p>
  <ul>
  <li>what is the difference between the <code>docker:dind</code> and the <code>docker:latest</code> images?</li>
  <li>(most importantly): <strong>why</strong> are <strong>both</strong> the service and the docker image needed (e.g. as indicated <a href="https://gitlab.com/gitlab-examples/docker/blob/master/.gitlab-ci.yml" rel="noreferrer">in this example</a>, linked to from the github documentation) to perform e.g. a <code>docker build</code> whithin a ci job? doesn't the <code>docker:latest</code> image (<strong>within which the job will be executed</strong>!) incorporate the docker daemon (and I think the <code>docker-compose</code> also), which are the tools necessary for the commands we need (e.g. <code>docker build</code>, <code>docker push</code> etc)?</li>
  </ul>
  <p>Unless I am wrong, the question more or less becomes:</p>
  <blockquote>
  <p>Why a docker client and a docker daemon cannot reside in the same docker (enabled) container</p>
  </blockquote>