CI转轮无法连接到unix

CI转轮无法连接到unix

本文介绍了GitLab CI转轮无法连接到unix:///var/run/docker.sock in kubernetes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GitLab在kubernetes群集中运行。运行者无法使用构建工件构建Docker映像。我已经尝试了几种方法来解决这个问题,但没有运气。以下是一些配置片段:



.gitlab-ci.yml

  image:docker:最新
服务:
- docker:dind

变量:
DOCKER_DRIVER:overlay

阶段:
- build
- package
- deploy

maven-build:
image:maven:3-jdk-8
stage:build
脚本:mvn package -b --settings settings.xml
工件:
路径:
- 目标/ *。jar

docker-build:
stage:package
script:
- docker build -t gitlab.my.com/group/app。
- docker login -u gitlab-ci-token -p $ CI_BUILD_TOKEN gitlab.my.com/group/app
- docker push gitlab.my.com/group/app

config.toml

  = 1 
check_interval = 0

[[runners]]
name =app
url =https://gitlab.my.com/ci
token =xxxxxxxx
executor =kubernetes
[runners.kubernetes]
privileged = true
disable_cache = true

包阶段日志:

  gitlab-ci-多人1.11.1(a67a225)
在应用程序运行器(6265c5)
使用Kubernetes命名空间:默认
使用Kubernetes执行器与图像docker:最新...
等待pod默认/ runner-6265c5-project-4-concurrent-0h9lg9正在运行,状态为Pending
等待pod default / runner-6265c5-project-4-concurrent-0h9lg9运行,状态为待处理
运行在runner-6265c5-project-4-concurrent-0h9lg9上gitlab-runner-3748496643-k31tf ...
克隆资料库
克隆到'/ group / app'...
签出10d5a680作为主...
跳过Git子模块设置
下载maven-build(61)...的工件...
从协调器下载工件... ok id = 61 responseStatus = 200 OK token = ciihgfd3W
$ docker build - t gitlab.my.com/group/app。
无法在unix:///var/run/docker.sock连接到Docker守护程序。 docker守护进程是否运行?
错误:作业失败:执行远程命令时出错:命令以非零退出代码终止:在Docker容器中执行错误:1

我做错了什么?

解决方案

不需要使用: p>

  DOCKER_DRIVER:overlay 


$ b $因为它似乎是OVERLAY不支持,所以svc-0容器无法从它开始:

  $ kubectl logs -f`kubectl get pod | awk'/ ^ runner / {print $ 1}'`-c svc-0 
time =2017-03-20T11:19:01.954769661Zlevel = warning msg = [!]不要绑定任何IP地址,无需设置-tlsverify如果您不知道该怎么办[!]
time =2017-03-20T11:19:01.955720778Z级别= info msg =libcontainerd:new containerd process,pid:20
time =2017-03-20T11:19:02.958659668Zlevel = error msg ='overlay'未找到作为受支持的文件系统主机,请确保内核足够新,并具有o verlay支持加载。

另外,添加 export DOCKER_HOST =tcp:// localhost:2375 到docker-build:

  docker-build:
stage:package
脚本:
- 导出DOCKER_HOST =tcp:// localhost:2375
- docker build -t gitlab.my.com/group/app。
- docker login -u gitlab-ci-token -p $ CI_BUILD_TOKEN gitlab.my.com/group/app
- docker push gitlab.my.com/group/app


GitLab's running in kubernetes cluster. Runner can't build docker image with build artifacts. I've already tried several approaches to fix this, but no luck. Here are some configs snippets:

.gitlab-ci.yml

image: docker:latest
services:
  - docker:dind

variables:
  DOCKER_DRIVER: overlay

stages:
  - build
  - package
  - deploy

maven-build:
  image: maven:3-jdk-8
  stage: build
  script: "mvn package -B --settings settings.xml"
  artifacts:
    paths:
      - target/*.jar

docker-build:
  stage: package
  script:
  - docker build -t gitlab.my.com/group/app .
  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN gitlab.my.com/group/app
  - docker push gitlab.my.com/group/app

config.toml

concurrent = 1
check_interval = 0

[[runners]]
  name = "app"
  url = "https://gitlab.my.com/ci"
  token = "xxxxxxxx"
  executor = "kubernetes"
  [runners.kubernetes]
    privileged = true
    disable_cache = true

Package stage log:

running with gitlab-ci-multi-runner 1.11.1 (a67a225)
  on app runner (6265c5)
Using Kubernetes namespace: default
Using Kubernetes executor with image docker:latest ...
Waiting for pod default/runner-6265c5-project-4-concurrent-0h9lg9 to be running, status is Pending
Waiting for pod default/runner-6265c5-project-4-concurrent-0h9lg9 to be running, status is Pending
Running on runner-6265c5-project-4-concurrent-0h9lg9 via gitlab-runner-3748496643-k31tf...
Cloning repository...
Cloning into '/group/app'...
Checking out 10d5a680 as master...
Skipping Git submodules setup
Downloading artifacts for maven-build (61)...
Downloading artifacts from coordinator... ok        id=61 responseStatus=200 OK token=ciihgfd3W
$ docker build -t gitlab.my.com/group/app .
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
ERROR: Job failed: error executing remote command: command terminated with non-zero exit code: Error executing in Docker Container: 1

What am I doing wrong?

解决方案

Don't need to use this:

DOCKER_DRIVER: overlay

cause it seems like OVERLAY isn't supported, so svc-0 container is unable to start with it:

$ kubectl logs -f `kubectl get pod |awk '/^runner/{print $1}'` -c svc-0
time="2017-03-20T11:19:01.954769661Z" level=warning msg="[!] DON'T BIND ON ANY IP ADDRESS WITHOUT setting -tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING [!]"
time="2017-03-20T11:19:01.955720778Z" level=info msg="libcontainerd: new containerd process, pid: 20"
time="2017-03-20T11:19:02.958659668Z" level=error msg="'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded."

Also, add export DOCKER_HOST="tcp://localhost:2375" to the docker-build:

 docker-build:
  stage: package
  script:
  - export DOCKER_HOST="tcp://localhost:2375"
  - docker build -t gitlab.my.com/group/app .
  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN gitlab.my.com/group/app
  - docker push gitlab.my.com/group/app

这篇关于GitLab CI转轮无法连接到unix:///var/run/docker.sock in kubernetes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 20:23