Error during connect: Post http://docker:2375/v1.40/auth: dial tcp: lookup docker on 169.254.169.254:53: no such host

Hello, yesterday we start to get this error during publish
error during connect: Post http://docker:2375/v1.40/auth: dial tcp: lookup docker on 169.254.169.254:53: no such host
Can you help me ?

1 Like

See Docker:dind stops working after 12.1.0 update

You might also want to use this approach instead: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-socket-binding

1 Like

Hi everyone! I want to share the solution!

just add image = docker:stable and privileged = true

and that’s all! enjoy!

3 Likes

I was having this issue and I follow the suggestion of @a.mashukov, now I’m getting a similar message but in the build stage.

my .gitlab-ci.yml:
# Official docker image.

image: docker:latest

services:

  - docker:dind

before_script:

  - echo "$CI_REGISTRY"

  - echo "$CI_REGISTRY_USER"

  - echo "$CI_REGISTRY_PASSWORD"

  - echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY --username $CI_REGISTRY_USER --password-stdin

Building image:

  stage: build

  tags:

    - build

    - docker

    - test

  script:

    - docker build --pull -t "$CI_REGISTRY_IMAGE"/my-image .

only:
  - master

And the output of the job:

`Checking out 2d606f0a as master...` `Skipping Git submodules setup ` `$ echo "$CI_REGISTRY"  ` `registry.gitlab.com` `$ echo "$CI_REGISTRY_USER"` `gitlab-ci-token` `$ echo "$CI_REGISTRY_PASSWORD"` `[MASKED]` `$ echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY --username $CI_REGISTRY_USER --password-stdin` `WARNING! Your password will be stored unencrypted in /root/.docker/config.json.` `Configure a credential helper to remove this warning. See` `https://docs.docker.com/engine/reference/commandline/login/#credentials-store` `Login Succeeded` `$ echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY --username $CI_REGISTRY_USER --password-stdin` `WARNING! Your password will be stored unencrypted in /root/.docker/config.json.` `Configure a credential helper to remove this warning. See` `https://docs.docker.com/engine/reference/commandline/login/#credentials-store` `Login Succeeded` `$ docker build --pull -t "$CI_REGISTRY_IMAGE"/staging/aruba-autos.com --build-arg DB_ROOT_PASSWORD=xt-d3f4ultp455w0rd --build-arg DB_NAME=aruba-autos.com --build-arg DOMAIN=staging.aruba-autos.com --build-arg THEME_REPOSITORY=git@gitlab.com:xenotrue/development/osclass_them_xt-curacaoproperties.git --build-arg SITE_ROOT_EXTRAS=git@gitlab.com:xenotrue/infrastructure/xt-web-solution-backups/curacao-properties.com/curacao-properties.com_site-root_extras.git --build-arg THEME_IMAGES=git@gitlab.com:xenotrue/infrastructure/xt-web-solution-backups/curacao-properties.com/curacao-properties.com_them_imag_uploads.git --build-arg UPLOADS_REPOSITORY=git@gitlab.com:xenotrue/infrastructure/xt-web-solution-backups/curacao-properties.com/curacao-properties.com_oc-content_uploads.git --build-arg PLUGIN_BANNERS=git@gitlab.com:xenotrue/development/osclass_plug_xt-banners.git --build-arg BANNERS_IMAGES=git@gitlab.com:xenotrue/infrastructure/xt-web-solution-backups/curacao-autos.com/curacao-autos.com_plug_bann_banners.git --build-arg PLUGIN_PACKAGES=git@gitlab.com:xenotrue/development/osclass_plug_xt-packages.git --build-arg PLUGIN_SOCIAL=git@gitlab.com:xenotrue/development/osclass_plug_social-bookmarks.git --build-arg PLUGIN_YOUTUBE=git@gitlab.com:xenotrue/development/osclass_plug_youtube.git --build-arg PLUGIN_PAYPRO=git@gitlab.com:xenotrue/development/osclas_payments-pro.git --build-arg INFRASTRUCTURE_SSH_PRIVATE_KEY="$INFRASTRUCTURE_SSH_PRIVATE_KEY" .` `Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?` `ERROR: Job failed: exit code 1`

Any help?

JUNE 2021: this worked for me:
stage: release
image: docker:latest
services:
- docker:18.09.7-dind
variables:
DOCKER_HOST: tcp://localhost:2375/

You might need to add --docker-network-mode "host" to the Gitlab runner config. Before doing that I got the following error (assuming “dind” is the hostname, not “docker”):

ERROR: error during connect: Get http://dind:2375/v1.40/info: dial tcp: lookup dind on 8.8.8.8:53: no such host

edit config.toml and change volumes option

before

[[runners]]
  ...
  [runners.docker]
    volumes = ["/cache"]
    ...

after

[[runners]]
  ...
  [runners.docker]
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    ...

issue

2 Likes

little improvement of edocollado answer

sed -i 's+    volumes = \["\/cache"\]+    volumes = \["\/cache", "\/var\/run\/docker.sock:\/var\/run\/docker.sock"\]+g' config.toml

Ok

image = docker:stable
privileged = true
volumes = [“/var/run/docker.sock:/var/run/docker.sock”, “/cache”]
Don`t work

official docs - sucks

What else to do?

1 Like

Example for building docker images that works as of February 2024:
It builds when the git repository is tagged in gitlab.

config.toml

[[runners]]
  name = "9ef08c0b1d3c"
  url = "gitlab.example.com"
  id = 19
  token = "XXX"
  token_obtained_at = 2024-02-05T01:44:17Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "docker:stable"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock","/cache"]
    pull_policy = ["if-not-present"]
    shm_size = 0
    network_mtu = 0

gitlab=ci.yml

variables:
  DOCKER_BUILDKIT: 1
 
docker-build:
  image: docker:24
  stage: build
  variables:
    DOCKER_DRIVER: overlay2
  before_script:
    - docker login -u $REGISTRY_USER -p $REGISTRY_PASSWORD registry.example.com
  script:
    - |
      if [ -z "$CI_COMMIT_TAG" ]
      then
        echo "Tag is empty, exiting..."
        exit 1
      fi
    - docker build --pull --tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" .
    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
    - echo "'Image built:' $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
  only:
    - tags
  when: on_success
1 Like

That configuration allows communication with the host’s docker daemon (i.e. the outside docker when doing docker-in-docker stuff) on the socket that gets created, and the error message talks about a tcp connection failing, I guess @mccarthysean gave an option to switch the docker setup to use the socket based communication (but I think I read somewhere that that is deprecated).

What I have in our runner config (/etc/gitlab-runner/config.toml) that is different from the configuration of the runner that doesn’t support docker-in-docker stuff is

...
  environment = ["DOCKER_TLS_CERTDIR=", "DOCKER_DRIVER=overlay2"]
...
  [runners.docker]
...
    image = "docker:latest"
    privileged = true
...

This completely work for me. You can try this
.gitlab-ci.yml

stages:
  - compile
  - deploy

compile-express:
  image: "node:8.10"
  stage: compile
  script:
    - npm install
  only:
    - develop
  tags:
    - shell-runner

build-docker-image:
  image: docker:latest
  services:
    - docker:18.09.7-dind
  stage: deploy
  environment: staging
  variables:
    CONTAINER_IMAGE: tsaniakhilya/simple-node-js:latest
    DOCKER_DRIVER: overlay2
    DOCKER_HOST: tcp://localhost:2375/
  before_script:
    - 'echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin'
  script:
    - 'ls'
    - 'docker build -t $CONTAINER_IMAGE .'
    - 'docker push $CONTAINER_IMAGE'
    - 'docker-compose down --rmi all'
    - 'docker-compose up -d'
    - 'docker container ls '
  only:
    - develop
  tags:
    - docker-runner

/etc/gitlab-runner/config.toml

[[runners]]
  name = "Docker Runner"
  url = "Your URL"
  id = Your ID
  token = "XXXX"
  token_obtained_at = 2024-11-13T05:00:49Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    MaxUploadedArchiveSize = 0
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "docker:stable"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    pull_policy = ["if-not-present"]
    shm_size = 0
    network_mtu = 0