我已经使用Helm在Kubernetes上安装了Gitlab,并试图让Auto DevOps工作,但我从Auto DevOps管道中得到以下问题:
Executing "step_script" stage of the job script 00:01
$ if [[ -z "$CI_COMMIT_TAG" ]]; then # collapsed multi-line command
$ /build/build.sh
Logging in to GitLab Container Registry with CI credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
Building Dockerfile-based application...
Attempting to pull a previously built image for use with --cache-from...
Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
No previously cached image found. The docker build will proceed without using a cached image
Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
Cleaning up file based variables 00:00
ERROR: Job failed: command terminated with exit code 1
我读过关于Docker-in-Docker的问题,但是我无法使它工作。
我也尝试设置DOCKER_HOST: tcp://docker:2375/
变量,但我仍然得到相同的错误。
Cannot connect to the Docker daemon at tcp://docker:2375/. Is the docker daemon running?
我的Gitlab Runner Helm值看起来像这样:
gitlabUrl: https://gitlab.mydomain.com
privileged: true
rbac:
create: true
runnerRegistrationToken: mytoken
runners:
config: |
[[runners]]
executor = "docker"
privileged = true
environment = ["DOCKER_TLS_CERTDIR="]
[runners.docker]
tls_verify = false
privileged = true
我尝试使用Auto-DevOps.gitlab-ci.yml
模板。
我的集群使用集群证书方法集成到Gitlab中,并运行简单的CI/CD,如
test_project:
stage: test
script:
- npm run test
没问题我尝试了docker:18.09.7
,docker:19.03.1
和docker:latest
(以及相应的-dind
服务,无论是否设置DOCKER_HOST: tcp://docker:2375/
)
我不知道我错过了什么。
//更新
我在Gitlab Support的帮助下解决了这个问题。我的问题是,我不得不使用[runners.kubernetes]
配置和设置privileged
到true
那里。我只是在[runners.docker]
中设置它,因为我认为Kubernetes Gitlab runner会这样配置。