gitlab-ci - Gitlab Auto Deploy 无法连接到 Docker
问题描述
我已经使用 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
and docker:latest
(以及相应的-dind
服务,有或没有设置DOCKER_HOST: tcp://docker:2375/
)
我不知道我错过了什么。
解决方案
// 更新
我在 Gitlab 支持的帮助下解决了这个问题。我的问题是我必须使用[runners.kubernetes]
配置并设置privileged
在true
那里。我只是将它设置[runners.docker]
为我认为 Kubernetes Gitlab Runners 会进行该配置。
推荐阅读
- datetime - 创建只有年、月和日的 DateTime.now() 的最佳方法?
- laravel - laravel 中的多个位置
- sql - SQL 查询以获取只有一个值的项目
- c++ - 即使我已经声明了朋友类,为什么我会收到错误“无法访问在类中声明的私有成员”
- mysql - 使用 MQTT 或远程 MySQL 在服务器上获取数据?
- scheme - 如何更改此功能,“汽车”出现问题
- python - 从给定的工作日和月份计算日期,但年份可变(例如,“x”年中 8 月的第 3 个星期日)
- html - 如何使用 Google Apps 从 html 表单中获取输入文本?
- sonic - Sonic Annotator 设置 VAMP 插件文件夹位置
- php - 使用 curl(命令行)将 POST 请求中的数据发送到 php-script 时清空 $_POST