title: How do I use docker to run a gitlab-runner for a gitlab-hosted project?
body: <p>I'm in the process of deploying a gitlab-runner to kubernetes on google-cloud-engine so can quickly scale runners / send the configuration off to other people so they can run their own runners. But first, I wanted to try to see if I could get the runner hooked up locally on my laptop.</p>
  
  <p>Setup
  I have a project that on gitlab that is public, but I don't think it matters, as the goal here is just to be able to run docker-based tests on the gitlab runner.
  With docker, I've proved to myself that it's possible via: <a href="https://github.com/NullVoxPopuli/vsts-agent-with-aws-ecr" rel="nofollow noreferrer">https://github.com/NullVoxPopuli/vsts-agent-with-aws-ecr</a> (a project I did for work)</p>
  
  <p>Here is what I have so far for the gitlab runner:</p>
  
  <pre><code>#/bin/bash
  docker stop gitlab-runner &amp;&amp; docker rm gitlab-runner
  
  docker run -d --name gitlab-runner --restart always \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /usr/local/gitlab-ci-runner/config:/etc/gitlab-runner \
    -v "$(pwd)/config.toml":/etc/gitlab-runner/config.toml:ro \
    gitlab/gitlab-runner:alpine
  
  docker exec -it gitlab-runner gitlab-runner register \
    -n \
    --url https://gitlab.com/ci \
    --tag-list "docker,docker-compose" \
    --run-untagged \
    --registration-token my-runner-token \
    --executor docker \
    --description "Docker Runner" \
    --docker-image "docker:dind" \
    --docker-volumes /var/run/docker.sock:/var/run/docker.sock \
    --docker-privileged
  </code></pre>
  
  <p>and here is my config.toml:</p>
  
  <pre><code>concurrent = 4
  
  [[runners]]
      name = "precognition-gitlab-runner"
      url = "https://gitlab.example.com/ci"
      token = "my-runner-token"
      executor = "docker"
      run_untagged = true
  
      [runners.docker]
        tls_verify = false
        image = "alpine"
        privileged = true
        disable_cache = false
        volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock"]
      [runners.cache]
        Insecure = false
  </code></pre>
  
  <p>Now, when I run the script that run the gitlab-runner and then registers it, I <em>do</em> see it in gitlab in <a href="https://gitlab.com/project_name/settings/ci_cd" rel="nofollow noreferrer">https://gitlab.com/project_name/settings/ci_cd</a></p>
  
  <p>But, it says that the runner has not connected yet:
  <a href="https://i.stack.imgur.com/syZZS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/syZZS.png" alt="enter image description here"></a></p>
  
  <p>What's the correct way to configure this?</p>
  
  <p>Here is my .gitlab-ci.yml for anyone curious: <a href="https://gitlab.com/precognition-llc/aeonvera-ui/blob/registration-rework/.gitlab-ci.yml" rel="nofollow noreferrer">https://gitlab.com/precognition-llc/aeonvera-ui/blob/registration-rework/.gitlab-ci.yml</a></p>
  
  <p>it just runs other scripts, which in-turn run docker-compose which then runs the tests.</p>