I am using GitLab along with GitLab runner and DIND.
Configuration details:
---------------------------------------
docker run --privileged --name gitlab-dind -d --restart=always docker:17.07-dind
---------------------------------------
cat gitlab_runner.sh
docker run -d --name gitlab-runner --restart always \
-v /mnt/data/gitlab/gitlab-runner:/etc/gitlab-runner \
--link gitlab-dind:docker \
gitlab/gitlab-runner:v9.5.0
---------------------------------------
cat /mnt/data/gitlab/gitlab-runner/config.toml
concurrent = 1
check_interval = 0
[[runners]]
name = "RunnerA"
url = "https://gitlab.dev.abc.net"
token = "d8ed43a69ebed74ccab2493857d8cb"
executor = "docker"
[runners.docker]
tls_verify = false
image = "docker:17.07"
privileged = false
disable_cache = false
volumes = ["/cache"]
host = "tcp://gitlab-dind:2375"
shm_size = 0
[runners.cache]
---------------------------------------
cat ~/wksp/test-proj/.gitlab-ci.yml
image: docker.artifactory.abc.net/docker:17.07
variables:
DOCKER_HOST: tcp://docker:2375
# This before_script block was added later but it seems this block
# isn't executed before the DIND tries fetching image from Artifactory
before_script:
- docker login -u svc-art-user -p some-pwd docker.artifactory.abc.net
- docker info
services:
- docker.artifactory.abc.net/docker:17.07-dind
build:
stage: build
script:
- docker build -t my-docker-node-image .
---------------------------------------
As an aside, in the above configuration, is DOCKER_HOST
config needed in .gitlab-ci.yml
or just the entry ( host = "tcp://gitlab-dind:2375
) in config.toml
suffice?
Now when the runner runs, i get the following error:
Runner log error:
Running with gitlab-ci-multi-runner 9.5.0 (413da38)
on RunnerA (d8ed43a6)
Using Docker executor with image docker.artifactory.abc.net/docker:17.07 ...
Starting service docker.artifactory.abc.net/docker:17.07-dind ...
Pulling docker image docker.artifactory.abc.net/docker:17.07-dind ...
ERROR: Preparation failed: Error response from daemon: Get https://docker.artifactory.abc.net/v2/: x509: certificate signed by unknown authority
I may be wrong but it seems this error is because the service account ( svc-art-user
) isn't able to login before the DIND image pull happens.
You need to provide authentication details to your Gitlab Runner because it needs to pull the image.
You need to create DOCKER_AUTH_CONFIG
secret variable with the authentication details as below
{
"auths": {
"docker.artifactory.abc.net": {
"auth": "bXlfdXNlcm5hbWU6bXlfcGFzc3dvcmQ="
}
}
}
This you can get by logging into docker locally and and checking ~/.docker/config.json
The documentation provides good details on this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.