How to fix Gitlab CI error during connect: Post http://docker:2375/v1.40/auth: dial tcp: lookup docker on … no such host. I spent more than 1 hour to fix it. And I am totally not sure that I will remember it 🙂

The source is here:

This error occurs with docker-based gitlab runners such as the one we’re that are configured using a docker executor. The error message means that the inner docker container doesn’t have a connection to the host docker daemon.

In order to fix this, set these options in [runners.docker] in your gitlab-runner config.toml:

privileged = true
volumes = ["/certs/client", "/cache"]'

The content of /etc/gitlab-runner/config.toml is:

concurrent = 1
check_interval = 0
shutdown_timeout = 0

  session_timeout = 1800

  name = "y docker-runner"
  url = ""
  id = 21389039
  token = "gitlab-runner-token-"
  token_obtained_at = 2023-02-24T09:56:32Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
    MaxUploadedArchiveSize = 0
    tls_verify = false
    image = "ruby:2.7"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/certs/client", "/cache"]
    shm_size = 0