Gitlab CI custom image with docker in docker

I am using a custom docker image to run my build because it needs some extra things to work.

At the end i want to build and push my docker images. While the build of my app works great I get an error when trying to build my docker image.

Executing task: DockerBuild
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
An error occurred when executing task ‘DockerBuild’.

I read all about the privilege flag etc. but according to this shared runners already have the privilege flag set to true.

Does anyone have an Idea what the problem could be?

Can you post your gitlab ci yml file?

image: franklin89/gitlab-cakebuild:latest
stages:
- build
build_job:
stage: build
script:
- cd build
- ./build.sh

also tried to add:

services:

  • docker:dind

According to this blog post, the only thing that should be done is to add /var/run/docker.sock:/var/run/docker.sock when running my custom image. But not sure if I can pass any volume mappings…

So, now i am totally confused.
If I use docker:latest as an image and just call - docker version as a script it works. As soon as take my custom docker image: franklin89/gitlab-cakebuild:latest the command fails.

This seems to be an issue with my image. But I have no clue what the problem is…

Anybody here that might be able to help me?

Your custom image is not dind compatible. Check the dockerfile of the dind image to see what you have to add.