How can I let the gitlab-ci-runner DinD image cache intermediate images? : <p>I have a Dockerfile that starts with installing the texlive-full package, which is huge and takes a long time. If I <code>docker build</code> it locally, the intermedate image created after installation is cached, and subsequent builds are fast.</p>

<p>However, if I push to my own GitLab install and the GitLab-CI build runner starts, this always seems to start from scratch, redownloading the <code>FROM</code> image, and doing the apt-get install again. This seems like a huge waste to me, so I'm trying to figure out how to get the GitLab DinD image to cache the intermediate images between builds, without luck so far.</p>

<p>I have tried using the <code>--cache-dir</code> and <code>--docker-cache-dir</code> for the <code>gitlab-runner register</code> command, to no avail.</p>

<p>Is this even something the gitlab-runner DinD image is supposed to be able to do?</p>

<p>My <code>.gitlab-ci.yml</code>:</p>

<pre><code>build_job:
    script:
    - docker build --tag=example/foo .
</code></pre>

<p>My <code>Dockerfile</code>:</p>

<pre><code>FROM php:5.6-fpm
MAINTAINER Roel Harbers &lt;roel.harbers@example.com&gt;
RUN apt-get update &amp;&amp; apt-get install -qq -y --fix-missing --no-install-recommends texlive-full
RUN echo Do other stuff that has to be done every build.
</code></pre>

<p>I use GitLab CE 8.4.0 and gitlab/gitlab-runner:latest as runner, started as</p>

<pre><code>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 \
    gitlab/gitlab-runner:latest \
; \
</code></pre>

<p>The runner is registered using:</p>

<pre><code>docker exec -it gitlab-runner gitlab-runner register \
    --name foo.example.com \
    --url https://gitlab.example.com/ci \
    --cache-dir /cache/build/ \
    --executor docker \
    --docker-image gitlab/dind:latest \
    --docker-privileged \
    --docker-disable-cache false \
    --docker-cache-dir /cache/docker/ \
; \
</code></pre>

<p>This creates the following <code>config.toml</code>:</p>

<pre><code>concurrent = 1
[[runners]]
    name = "foo.example.com"
    url = "https://gitlab.example.com/ci"
    token = "foobarsldkflkdsjfkldsj"
    tls-ca-file = ""
    executor = "docker"
    cache_dir = "/cache/build/"
    [runners.docker]
        image = "gitlab/dind:latest"
        privileged = true
        disable_cache = false
        volumes = ["/cache"]
        cache_dir = "/cache/docker/"
</code></pre>

<p>(I have experimented with different values for <code>cache_dir</code>, <code>docker_cache_dir</code> and <code>disable_cache</code>, all with the same result: no caching whatsoever)</p>
