[GITLAB RUNNER – self hosted] Fix for Docker in Docker (DinD)

1.1 Gitlab CI Job fails with self hosted Gitlab group runner

1.2 The self hosted Gitlab runner (executable on Linux VM) is not configured properly to use DinD

1.3 Set proper values for “tls_verify”, “image” and “privileged”
1.4 Gitlab CI Job is now OK with self hosted runner

2.1 Also change the Gitlab CI Pipeline configuration (variables “DOCKER_HOST” and DOCKER_TLS_CERTDIR”)

2.2 Change Gitlab Job configuration (image, services, before_script)

Source: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-in-docker

2.3 THIS SOLUTION IS POTENTIALLY UNSAFE – ALTERNATIVE

Alternative is to use kaniko to create the docker image.

kaniko solves two problems with using the Docker-in-Docker build method:

* Docker-in-Docker requires privileged mode to function, which is a significant security concern.
* Docker-in-Docker generally incurs a performance penalty and can be quite slow.

Source: Use kaniko to build Docker images | GitLab


Leave a comment