1 year ago

#366339

test-img

appdeveloper

Why docker can't connect to host while running Gitlab runner?

I'm getting this error output from gitlab runner I have installed locally:

error during connect: Get "http://docker:2375/v1.24/containers/json?all=1&filters=%7B%22label%22%3A%7B%22com.docker.compose.project%3Dproject-0%22%3Atrue%7D%7D&limit=0": dial tcp: lookup docker on 192.168.1.254:53: no such host Test failed: users users-lint client ERROR: Job failed: exit code 1

FATAL: exit code 1

my config.toml file:

concurrent = 1
check_interval = 0

[[runners]]
  name = "tdd"
  url = "https://gitlab.com/"
  token = "redacted_XXXXXXXX"
  executor = "docker"
  builds_dir = "~/tdd"
  [runners.docker]
    tls_verify = false
    disable_entrypoint_overwrite = false
    image = "docker:stable"
    privileged = true
    oom_kill_disable = false
    disable_cache = false
    cache_dir = ""
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]

taking a look at .gitlab-ci.yml file may help:

image: docker:stable

# services:
#    - docker:dind


variables:
  DOCKER_DRIVER: overlay
  DOCKER_HOST: tcp://docker:2375
  POSTGRES_DB: users_dev
  POSTGRES_USER: postgres
  POSTGRES_PASSWORD: postgres
  POSTGRES_HOST: postgres


stages:
  - build

before_script:
  - apk update
  - apk add --no-cache --update python3-dev py3-pip curl
  - curl -L https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-`uname -s`-`uname -m` > docker-compose
  - chmod +x docker-compose
  - mv docker-compose /usr/local/bin
  - export REACT_APP_USERS_SERVICE_URL=http://127.0.0.1
  - export SECRET_KEY=hakuna000matata

build:
  stage: build
  script:
    - sh test.sh

I commented out services because it works OK for CI environment but threads on the web suggests that it's better to keep it off when running the build locally. Any ideas what may help ? I'm on Ubuntu.

docker

gitlab

gitlab-ci-runner

0 Answers

Your Answer

Accepted video resources