Often we want to test CI tasks in local environment. Docker in docker (dind) is helpful for running CI tasks locally. We use two images, docker:dind and docker, and a docker network to communicate between two instances.

docker network create gitlab
docker run --name docker --privileged --network gitlab -d docker:dind
docker run --network gitlab -v $PWD:/opt/base -ti docker /bin/sh
export DOCKER_HOST=tcp://docker:2375

After these steps, we have current directory mapped in /opt/base where we can run docker build to test images or CI tasks.

docker info
cd /opt/base
docker build -t xydinesh/base .