I want to build a project using a GitLab runner. That project uses the
docker-maven-plugin. The Runner is configured to use privileged mode as advised by GitLab for Docker-in-Docker.
I am able to build the project locally on my computer both under Windows and Mac OS.
The relevant part of the
.gitlab-ci.yml looks as follows:
stages: - build variables: DOCKER_HOST: tcp://docker:2375 services: - docker:dind Validate: image: cschockaert/docker-npm-maven:latest stage: build tags: - dind script: - mvn clean install
However, the GitLab runner yields the following error message:
[ERROR] DOCKER> Cannot create docker access object [Cannot extract API version from server http://localhost:2375 : Connect to localhost:2375 [localhost/127.0.0.1] failed: Connection refused (Connection refused)]
I know that when building my project locally, I have to activate the option to listen on port 2375 on Windows or, alternatively, run
socat TCP-LISTEN:2375,reuseaddr,fork UNIX-CONNECT:/var/run/docker.sock on Mac OS as advised in this thread. To my knowledge, setting
DOCKER_HOST: tcp://docker:2375 should have the same effect on the GitLab runner. Replacing it by
DOCKER_HOST: tcp://localhost:2375 leads to the same results.
I also checked that
DOCKER_HOST is really set by running
env | grep DOCKER as advised by this answer.