These are the steps I followed to setup a custom Gitlab runner:
Install Gitlab runner by following the instructions here: https://docs.gitlab.com/runner/install/linux-repository.html
Register a runner with
dockerexectuor anddocker:19imageWrite
gitlab-ci.ymlas follow:
image: docker:19.03.1
services:
- name: docker:19.03.1-dind
alias: docker
stages:
- build
build:
stage: build
variables:
IMAGE_TAG: repo.azurecr.io/some-repo
DOCKER_HOST: tcp://172.17.0.1:2375
DOCKER_TLS_CERTDIR: ''
script:
- docker login someacr.azurecr.io -u "$SERVICE_PRINCIPAL_USER" -p "$SERVICE_PRINCIPAL_PASSWORD"
- if [[ "$CI_COMMIT_REF_NAME" == "develop" ]]; then docker build -t $IMAGE_TAG .; fi
- Running the pipeline throws this error:
Login succeeded
if [[ "$CI_COMMIT_REF_NAME" == "develop" ]]; then docker build -t $IMAGE_TAG .; fi
Cannot connect to the Docker daemon at tcp://172.17.0.1:2375. Is the docker daemon running?
Cleaning up project directory and file based variables
00:02
ERROR: Job failed: exit code 1
This is what I have tried so far:
privileged: truein/etc/gitlab-runner/config.tomldind:19docker image ingitlab-ci.yml- adding
volumes = ["/var/run/docker.sock /var/run/docker.sock" "/cache"]in/etc/gitlab-runner/config.toml - used
DOCKER_TLS_CERTDIR: ''ingitlab-ci.ymlas variable - populating
DOCKER_HOSTvariable withDOCKER_HOST: tcp://172.17.0.1:2375 - much more...
All these changes result in either of the 2 issues described in Gitlab Runner Troubleshooting here: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#troubleshooting
- docker: Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?
- Docker no such host error.