Use local docker images with gitlab-runner exec docker
I would like to debug my build locally but I would like to avoid having to build the docker image once again (I have it locally to develop, but I would have to build it again for gitlab-runner).
In order to do so, I'm mounting a volume of the Docker socket file and passing it to the docker executor, but docker can't see my images (in my test stage, I have a docker images to see what is available):
$ docker run --rm -it -v "$PWD":"$PWD" --workdir "$PWD" -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:alpine-v10.7.1 exec docker --docker-privileged --docker-pull-policy if-not-present --docker-volumes /var/run/docker.sock:/var/run/docker.sock test
WARNING: You most probably have uncommitted changes.
WARNING: These changes will not be tested.
Running with gitlab-runner 10.7.1 (b9bba623)
Using Docker executor with image docker:stable-git ...
Starting service mysql:5.7.20 ...
Using locally found image version due to if-not-present pull policy
Using docker image sha256:7d83a47ab2d2d0f803aa230fdac1c4e53d251bfafe9b7265a3777bcc95163755 for mysql:5.7.20 ...
Starting service docker:stable-dind ...
Using locally found image version due to if-not-present pull policy
Using docker image sha256:824b0ae8cb2720f6720011514c89e50c51164a55bc1ae7455957f8c9ba68e782 for docker:stable-dind ...
Waiting for services to be up and running...
Using locally found image version due to if-not-present pull policy
Using docker image sha256:8ff9a0906a2df739786ad21cb069498fe7ef3ce6716097e5de0e07f6bb9b7f18 for docker:stable-git ...
Running on runner--project-0-concurrent-0 via dd48fe7c4696...
Skipping Git repository setup
Skipping Git checkout
Skipping Git submodules setup
$ # Auto DevOps variables and functions # collapsed multi-line command
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
Job succeeded
What am I doing wrong ?