HiveBrain v1.2.0
Get Started
← Back to all entries
debugdockerMinor

Gitlab CI error during connect: Get http://docker:2375/v1.40/containers/json?all=1: dial tcp: lookup docker on xx.xx.xx.x:xx: no such host

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
sucherrorconnectallduringgitlabdockertcpjson2375

Problem

I've recently created a new repository in gitlab.com, started a new Ubuntu instance in digitalocean, installed docker and gitlab-runner in the ubuntu instance. Also, did gitlab-runner register and passed the correct host and token from gitlab.com ci/cd settings. Pushed a branch, and the expected pipeline job runs but fails, presenting the error:

error during connect: Get http://docker:2375/v1.40/containers/json?all=1: dial tcp: lookup docker on 67.207.67.2:53: no such host


Just followed the basic steps and expected it to work perfectly. By looking for the error when google search, there's no info.

The config.toml file, which is created automatically on gitlab-runner register:

concurrent = 1
check_interval = 0

[[runners]]
  name = "digital ocean runner"
  url = "https://gitlab.com/"
  token = "xxxxxxxxxxxxxxxxx"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "ruby:2.1"
    privileged = true
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
  [runners.cache]


The gitlab ci file:

image: docker:latest
services:
  - docker:dind
stages:
  - test

test-build:
  stage: test
  script:
    - echo "Fine!"
    - docker info
  tags:
    - docker


Steps to reproduce

open a gitlab.com account
Install Ubuntu latest
Install gitlab-runner
do `register` and should have the config.toml above


What causes this issue?

The error log for one one of the tests, not for the job above:

```
Running with gitlab-runner 12.3.0 (a8a019e0)
on foobar laptop szWcjfZg
Using Docker executor with image foobar/docker-bash ...
Starting service docker:dind ...
Authenticating with credentials from /Users/foobar/.docker/config.json
Pulling docker image docker:dind ...
Using docker image sha256:5768e15eefd175c1ba6969b616cfe827152556c5fe691b9258cb57d1a5c37e9d for docker:dind ...
Waiting for services to be up and running...

*** WARNING: Service runner-szWcjfZg-project-14670943-concurrent-0-docker-0 probably didn't start pr

Solution

I might have skipped the optional installation of docker in my Ubuntu instance, so if the gitlab runner is going to use Docker, remember to install it:

curl -sSL https://get.docker.com/ | sh


I got back to this issue and seem to have partially fixed it by checking it the gitlab runner is running

gitlab-runner status

systemctl is-enabled gitlab-runner

systemctl is-enabled docker


I do have a different issue to solve, but it doesn't seem to be related. That is:

error during connect: Post http://docker:2375/v1.40/images/ [...] dial tcp: lookup docker on xx.xxx.xx.x:xx: no such host


Then I found the solution, there's a problem in Gitlab CI that is reported here ( https://gitlab.com/gitlab-org/gitlab-runner/issues/4566#note_199261985 ); And there are a lot of ways to fix this but my solution follows:

1) Set the .gitlab-ci.yml services to use an older dind version:

services:
  - docker:18.09.7-dind


2) Check the toml file /etc/gitlab-runner/config.toml, set the DOCKER_HOST just in case, to point to the right place, make sure it runs in privileged mode. My working version is:

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "xxxxxx xxxxxxxx"
  url = "https://gitlab.com/"
  token = "xxxxxxxxxx"
  executor = "docker"
  pre_build_script = "export DOCKER_HOST=tcp://docker:2375"
  [runners.custom_build_dir]
  [runners.docker]
    tls_cert_path = ""
    tls_verify = false
    image = "alpine:latest"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]


Hope this helps someone else in the future!

Code Snippets

curl -sSL https://get.docker.com/ | sh
gitlab-runner status

systemctl is-enabled gitlab-runner

systemctl is-enabled docker
error during connect: Post http://docker:2375/v1.40/images/ [...] dial tcp: lookup docker on xx.xxx.xx.x:xx: no such host
services:
  - docker:18.09.7-dind
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "xxxxxx xxxxxxxx"
  url = "https://gitlab.com/"
  token = "xxxxxxxxxx"
  executor = "docker"
  pre_build_script = "export DOCKER_HOST=tcp://docker:2375"
  [runners.custom_build_dir]
  [runners.docker]
    tls_cert_path = ""
    tls_verify = false
    image = "alpine:latest"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

Context

StackExchange DevOps Q#9359, answer score: 9

Revisions (0)

No revisions yet.