Brandon Kauffman
Brandon Kauffman

Reputation: 1864

Gitlab runner failing ERROR: Cannot connect to the Docker daemon at local runner

I have a local runner that cannot connect to the docker daemon.

I tried adding an alias to the service and it still failed

ERROR: Cannot connect to the Docker daemon at tcp://docker:2375/. Is the docker daemon running?

ERROR: Cannot connect to the Docker daemon at tcp://thealias:2375/. Is the docker daemon running?

gitlab-ci

push_image:
  image: docker:20.10.16-dind

  services:
    - docker:20.10.16-dind

  before_script:
    - docker info
    - docker login ext_registry.com -u $NEXUS_USER -p $NEXUS_PASS
  script:
    - docker build -t ext_registry.com.liberty.edu:5000/occ/groupsyncer:latest .

gitlab-runner.toml

[[runners]]
  name = "docker-runner"
  url = "https://gitlab.example.com/"
  token = REDACTED
  executor = "docker"
  cache_dir="/cache"
  clone_url = "https://gitlab.example.com"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    volumes = ["/opt/gitlab-runner/cache:/cache:rw"]
    tls_verify = false
    image = "docker:20.10.16"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    shm_size = 0

Upvotes: 0

Views: 2005

Answers (1)

Brandon Kauffman
Brandon Kauffman

Reputation: 1864

In my case the error came from not sharing the docker sock.

  [runners.docker]
    volumes = ["/var/run/docker.sock:/var/run/docker.sock","/opt/gitlab-runner/cache:/cache:rw"]

Also make sure the gitlab-runner has permissions to docker.

usermod -aG docker gitlab-runner

Upvotes: 1

Related Questions