簡體   English   中英

gitlab-runner docker exeuctor (dind) - Error https://docker:2375/v1.40/info dial tcp: lookup docker on

[英]gitlab-runner docker exeuctor (dind) - Error https://docker:2375/v1.40/info dial tcp: lookup docker on

我遇到了 gitlab-runner 執行程序 docker 的問題。 在我運行我的 gitlab-ci.yml 文件后,管道在before_script期間的步驟docker info上失敗:

Running with gitlab-runner 13.10.0 (54944146)
  on docker-runner N2_yEgUD
Preparing the "docker" executor 00:07
Using Docker executor with image docker:19.03.0 ...
Starting service docker:19.03.0-dind ...
Pulling docker image docker:19.03.0-dind ...
Using docker image sha256:fd0c64832f7e46b63a180e6000dbba7ad7a63542c5764841cba73429ba74a39e for docker:19.03.0-dind with digest docker@sha256:442ac4b31375cbe617f31759b5199d240f11d5f430e54946575b274b2fb6f096 ...
Waiting for services to be up and running...
.............................................................................................
$ docker info
Client:
 Debug Mode: false
Server:
ERROR: error during connect: Get https://docker:2375/v1.40/info: dial tcp: lookup docker on 127.0.0.53:53: server misbehaving
errors pretty printing info
Cleaning up file based variables 00:01
ERROR: Job failed: exit code 1

我對堆棧和官方 gitlab 論壇進行了研究,但沒有一個答案可以解決我的問題:

  • 添加到.toml -> volume: ['/certs/client']
  • 對抗舊: docker:18.xx / docker:18.xx -dind | docker:stable / docker:dind
  • 運行: DOCKER_TLS_CERTDIR:""
  • 有/無運行:
  DOCKER_HOST: tcp://docker:2375/
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: "/certs" 
  • 將端點添加到服務:
services:
  - name: docker:dind
    entrypoint: ["env", "-u", "DOCKER_HOST"]
    command: ["dockerd-entrypoint.sh"]

gitlab-runner toml的內容

concurrent = 1
check_interval = 0
log_level = "debug"

[session_server]
  session_timeout = 1800

[[runners]]
  name = "docker-runner"
  url = "xxxxxxxx"
  token = "xxxxxxx"
  executor = "docker"
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    privileged = true
    image = "docker:19.03.12"
    disable_cache = false
    volumes = ["/cache", "/certs/client"]
    network_mode = "host"

gitlab-ci.yml 的內容

image: docker:19.03.0

services:
  - docker:19.03.0-dind

stages:
  - build
  - test_framework

variables:
  DOCKER_HOST: tcp://docker:2375/
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: "/certs" 
  CONTAINER_TEST_IMAGE: xxxx
  CONTAINER_RELEASE_IMAGE: xxxx

before_script:
  - docker info
  - docker login -u xxxx -p $CI_JOB_TOKEN xxxx

build:
  stage: build
  tags:
    - adm-docker
  script:
    - docker pull $CONTAINER_RELEASE_IMAGE || true
    - docker build -t $CONTAINER_TEST_IMAGE --cache-from $CONTAINER_RELEASE_IMAGE .
    - docker push $CONTAINER_TEST_IMAGE
  timeout: 1 hours

.test_commit: &test_commit
  stage: test_framework
  image: $CONTAINER_TEST_IMAGE
  tags:
    - adm-docker
  timeout: 1 hours
  artifacts:
    reports:
      junit: 'results/xunit.xml'
    expire_in: 1 day
  except:
    - master

test-unit:
  <<: *test_commit
  script:
    - python3 -m pytest --junitxml=results/xunit.xml test_unit/

只有一件事可以解決問題(解決方法問題)。 當我添加到 .toml volume: ["/var/run/docker.sock:/var/run/docker.sock"]

但在那之后,我失去了在test階段使用不同圖像運行我的 gitlab-ci.yml 的 DIND 可能性(不使用腳本:-docker run MY_IMAGE python3 ....)。 這不是我想要的

gitlab-runner under Ubuntu20 / Docker version 20.10.5, build 55c4c88

大約 1 年前,我使用過非常相似的 gitlab-ci.yml,並且 docker 執行器沒有問題

有什么想法/建議嗎?

我能夠通過更改 gitlab-ci.yml 的流程來解決問題

image: docker:19.03.5

services:
  - docker:19.03.5-dind

stages:
  - build
  - test_framework
  - release
    
variables:
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: ""
  CONTAINER_TEST_IMAGE: xxxxx
  CONTAINER_RELEASE_IMAGE: xxxxx

build:
  stage: build
  tags:
    - adm-docker
  before_script:
    - docker info
    - docker login -u xxxxx -p $CI_JOB_TOKEN xxxxx
  script:
    - docker pull $CONTAINER_RELEASE_IMAGE || true
    - docker build -t $CONTAINER_TEST_IMAGE --cache-from $CONTAINER_RELEASE_IMAGE .
    - docker push $CONTAINER_TEST_IMAGE
  timeout: 1 hours

.test_commit: &test_commit
  stage: test_framework
  tags:
    - adm-docker
  timeout: 1 hours
  artifacts:
    reports:
      junit: 'results/xunit.xml'
    expire_in: 1 day
  except:
    - master

test-unit:
  <<: *test_commit
  image: $CONTAINER_TEST_IMAGE 
  script: 
    - python3 -m pytest --junitxml=results/xunit.xml test_unit/

和 toml

[[runners]]
  name = "docker-runner"
  url = xxxxx
  token = xxxxx
  executor = "docker"
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    privileged = true
    image = "docker:19.03.12"
    disable_cache = false
    volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock"]
    network_mode = "host"

問題已由volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock"]修復

測試階段的問題是:

  before_script:
    - docker info
    - docker login -u xxxxx -p $CI_JOB_TOKEN xxxxx

在.yml 文件的根結構中。 我不得不移動它來build stage

我希望這對未來的人有所幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM