Search code examples
dockerdocker-in-docker

Pre-pull images in Docker in Docker (dind)


I am running a docker-in-docker container that always uses the same few images. I would like to pre-pull those in my dind container so I don't have to pull them at startup. How would I be able to achieve this?

I was thinking of building my own dind image along the lines of

FROM docker:18.06.1-ce-dind

RUN apk update && \
    apk upgrade && \
    apk add bash

RUN docker pull pre-pulled-image:1.0.0

Obviously above Dockerfile will not build because docker is not running during the build, but it should give an idea of what I'd like to achieve.


Solution

  • You can't do this.

    If you look at the docker:dind Dockerfile it contains a declaration

    VOLUME /var/lib/docker
    

    That makes it impossible to create a derived image with any different content in that directory tree. (This is the same reason you can't create a mysql or postgresql image with prepopulated data.)