title: What is the result of mounting `/var/run/docker.sock` in a Docker in Docker scenario?
body: <p>I've read <a href="https://stackoverflow.com/questions/35110146/can-anyone-explain-docker-sock/35110344">Can anyone explain docker.sock</a> to understand what <code>/var/run/docker.sock</code> does, but its use in GitLab CI's <a href="https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-socket-binding" rel="nofollow noreferrer">Use Docker socket binding</a> has me confused.</p>
  <p>Here is their example command for the <code>gitlab-runner</code> registration:</p>
  <pre><code>sudo gitlab-runner register -n \
    --url https://gitlab.com/ \
    --registration-token REGISTRATION_TOKEN \
    --executor docker \
    --description &quot;My Docker Runner&quot; \
    --docker-image &quot;docker:19.03.12&quot; \
    --docker-volumes /var/run/docker.sock:/var/run/docker.sock
  </code></pre>
  <p>I see two places that the resulting container could obtain <code>docker</code> from.</p>
  <ol>
  <li>The unix socket <code>/var/run/docker.sock</code>.</li>
  <li>The <code>docker</code> binary included in the base image <code>docker:19.03.12</code>.</li>
  </ol>
  <p>Isn't this a <code>PATH</code> conflict? I thought it should be one or the other, where I obtain the ability to use <code>docker</code> from either the host's unix socket or the base image.</p>
  <p>I would think that <code>--docker-image</code> should instead be <code>ubuntu:latest</code> or something along those lines that doesn't come with <code>docker</code>, since the <code>PATH</code>'s <code>docker</code> would already come from the host socket. Alternatively, the docker socket mount would be removed.</p>
  <p>What is actually happening here in regards to this double inclusion of <code>docker</code>?</p>