Let’s start with what I want to achieve: I’d like my pipeline to build Docker images from files in my repo.
I’m using the gitlab/gitlab-runner image on the same host as my gitlab container.
I managed to register the runner and the pipeline starts working but here’s where it all fails.
When I start my runner without -v /var/run/docker.sock:/var/run/docker.sock I get the following error message when invoking the pipeline:
Using Docker executor with image docker:dind …
ERROR: Preparation failed: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
When bind mounting it I get this one:
Cloning into ‘/builds/…’…
fatal: unable to access 'http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@…: SSL certificate problem: unable to get local issuer certificate
Clearly some container is missing the certificate of my gitlab instance. But which? I haven’t grasped the concept of DinD yet. Which container performs which task?
What does the image specified by the image tag in the .gitlab-ci.yml do?
What does the service (docker:dind) specified by the image tag in the .gitlab-ci.yml do?
What does the image specified in the config.toml do?
My .gitlab-ci-yml:
image: docker:stable
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
services:
- docker:dind
before_script:
- docker info
# See https://docs.gitlab.com/ce/ci/yaml/README.html
# start with build stage
stages:
- build
#- test
#- deploy
build: # a job with the name build
stage: build
tags: # The tags here determine which runner is allowed to run this job. Only runners with the same tag are allowed
- testtag
script:
- docker build -t myImage .
- docker push myRegistry
My config.toml
concurrent = 1
check_interval = 0
[[runners]]
name = "Testrunner"
url = "http://gitlabhost"
token = "XXX"
executor = "docker"
[runners.docker]
tls_verify = false
image = "docker:git"
privileged = true
disable_cache = false
volumes = ["/cache"]
shm_size = 0
[runners.cache]