docker - Gitlab - 使用“docker in docker”服务的作业导致“无法连接到 Docker 守护程序”
问题描述
我已经添加:
services:
- docker:dind
到我的 .gitlab-ci.yaml 文件,但是它似乎仍然没有运行 docker 守护程序。是否需要额外配置?
我在 Kubernetes 上使用 Gitlab Runner - 直接通过 Gitlab Web 界面/管理员安装。
image: docker:latest
services:
- docker:dind
stages:
- build
- deploy
build-web:
stage: build
script:
- docker info
only:
- master
deploy-web:
stage: deploy
script:
- docker info
- exit 1
only:
- master
构建输出:
Running with gitlab-runner 12.2.0 (a987417a)
on runner-gitlab-runner-857c466884-kzql9 BB7a6A8L
Using Kubernetes namespace: gitlab-managed-apps
Using Kubernetes executor with image docker:latest ...
Waiting for pod gitlab-managed-apps/runner-bb7a6a8l-project-1-concurrent-0prm8w to be running, status is Pending
Waiting for pod gitlab-managed-apps/runner-bb7a6a8l-project-1-concurrent-0prm8w to be running, status is Pending
Running on runner-bb7a6a8l-project-1-concurrent-0prm8w via runner-gitlab-runner-857c466884-kzql9...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/root/cinema/.git/
Created fresh repository.
From http://mygitlab.ddns.net/root/cinema
* [new branch] master -> origin/master
Checking out e138a25e as master...
Skipping Git submodules setup
$ docker info
Client:
Debug Mode: false
Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
ERROR: Job failed: command terminated with exit code 1
我在 gitlab runner pod 中看到以下配置:
bash-4.4$ cat .gitlab-runner/config.toml
listen_address = "[::]:9252"
concurrent = 4
check_interval = 3
log_level = "info"
[session_server]
session_timeout = 1800
[[runners]]
name = "runner-gitlab-runner-857c466884-kzql9"
request_concurrency = 1
url = "http://mygitlab.ddns.net/"
token = "BB7a6A8LRvZ4Y-9KsLvj"
executor = "kubernetes"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.kubernetes]
host = ""
bearer_token_overwrite_allowed = false
image = "ubuntu:16.04"
namespace = "gitlab-managed-apps"
namespace_overwrite_allowed = ""
privileged = true
service_account_overwrite_allowed = ""
pod_annotations_overwrite_allowed = ""
[runners.kubernetes.pod_security_context]
[runners.kubernetes.volumes]
解决方案
警告:以下内容可能不是 100% 安全的
似乎是这里提到的问题:https ://gitlab.com/gitlab-org/gitlab-runner/issues/4501
此处提供了一种解决方法:https ://gitlab.com/gitlab-org/gitlab-runner/issues/4501#note_194648457
基本上设置如下:
# .gitlab-ci.yml
variables:
DOCKER_TLS_CERTDIR: ""
推荐阅读
- javascript - 这两种发布方法 [Typescript] 之间有什么区别吗?
- flutter - Flutter Web:CORS 策略已阻止在 ** 从源 ** 访问 XMLHttpRequest
- xcode - 架构 x86_64 的未定义符号:clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- python - 尝试使用计数器检查值是否在范围内
- azure-resource-manager - Azure ARM 模板 - 将 virtualMachines/extensions 与 CopyIndex 一起使用
- twitter - 如何获取喜欢我的推文的用户列表和引用转发我的推文的用户列表?
- kubernetes - Kubernetes:如果我们已经有了 HPA,那么资源限制有什么用?
- mysql - 有没有办法使用合并语句将此查询转换为 Oracle 查询?
- c# - 在无法覆盖触发方法的情况下并行运行方法
- qt - 我可以使用正则表达式从句子中提取两个单词吗?