title: gitlab runner - how to cache images rather than build every time?
body: <p>I have setup gitlab runner to make use of the <code>docker/compose:latest</code> image to run a set of services.</p>
  <p>By setting <code>    pull_policy=&quot;if-not-present&quot;</code> in the <code>config.toml</code> the <code>docker/compose:latest</code> image is cached and not pulled each time.</p>
  <p>How can I set the docker service used in the test stage to use cached images (i.e. those being started using <code>docker-compose up -d</code> )? I'm a bit confused by the <code>dind</code> service.</p>
  <p><code>.gitlab-ci.yml</code></p>
  <pre class="lang-yaml prettyprint-override"><code>variables:
    DOCKER_HOST: tcp://docker:2375
    DOCKER_TLS_CERTDIR: &quot;&quot;
    DOCKER_DRIVER: overlay2
    CI_REGISTRY: my-docker-registry.local:5000
  
  image:
    name: docker/compose:latest
  
  services:
    - name: docker:dind
      command: [&quot;--insecure-registry=my-docker-registry.local:5000&quot;]
  
  test:
    stage: test
    script:
      - docker-compose up -d
  </code></pre>
  <p><code>/etc/gitlab-runner/config.toml</code> as follows:</p>
  <pre><code>                                                   concurrent = 1
  check_interval = 0
  
  [[runners]]
    name = &quot;user1&quot;
    url = &quot;http://gitlab.example.local/&quot;
    token = &quot;&lt;MYTOKEN&gt;&quot;
    executor = &quot;docker&quot;
    [runners.docker]
      extra_hosts = [&quot;my-docker-registry.local:192.168.1.100&quot;]
      tls_verify = false
      tls_verify = false
      image = &quot;docker:latest&quot;
      privileged = true
      disable_cache = false
      pull_policy=&quot;if-not-present&quot;
      volumes = [&quot;/certs/client&quot;, &quot;/cache&quot;]    
      disable_entrypoint_overwrite = false
      oom_kill_disable = false
      shm_size = 0
    [runners.cache]
  
  </code></pre>