ERROR: error during connect: Get "http://docker:2375/_ping": dial tcp: lookup docker on 10.10.15.22:53: server misbehaving

With the help of Docker and gitlab-runner, I set up a system that automatically converts the project to exe when pushed to the repository and versions it in gitlab release. I did this in a different project. Now I need to integrate it into this project. I got one of the errors I encountered in the previous project, but I could not solve the problem with the same solution.

My yml file is as follows;

default:
  image: docker:24.0.7
  services:
    - name: docker:24.0.7-dind


variables:
  DOCKER_TLS_CERTDIR: "/certs"

stages:
  - prepare_release
  - release

prepare_release:
  stage: prepare_release
  before_script:
    - echo "Setting up packages for Build"
    - apk --no-cache add zip
    - apk --no-cache add git
  rules:
    - if: '$CI_COMMIT_TAG'
  script:
    - docker buildx build -t demo-image --platform linux/arm64 . --build-arg TAG=$TAG
    - container_id=$(docker run -d -t demo-image)
    - mkdir -p artifacts/dist
    - docker cp $container_id:/app/dist ./artifacts/dist
    - echo "Zip distribution folder for Artifacts"
    - zip -r artifacts.zip ./artifacts/dist
    - echo "JOB_ID=$CI_JOB_ID" >> artifacts/job.env
    - PREVIOUS_TAG=$(git tag --sort=v:refname | tail -n 2 | head -n 1)
    - echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> artifacts/job.env
    - COMMIT_LIST=$(git log --oneline $PREVIOUS_TAG..$CI_COMMIT_TAG)
    - echo "COMMIT_LIST=$COMMIT_LIST" >> artifacts/job.env

  after_script:
    - cat artifacts/job.env
  artifacts:
    paths:
      - artifacts/
    expire_in: never
    reports:
      dotenv: artifacts/job.env

create_release:
  stage: release
  before_script:
    - echo "Setting up packages for Build"
    - apk --no-cache add git
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  needs:
    - job: prepare_release
      artifacts: true
  variables:
    TAG: '$CI_COMMIT_TAG'
  script:
    - echo "Running the release job."
    - echo "JOB ID=$JOB_ID"
    - echo "PREV TAG=$PREVIOUS_TAG"
    - echo "commits=$COMMIT_LIST"
  rules:
    - if: '$CI_COMMIT_TAG'
  release:
    name: 'Version $TAG'
    tag_name: '$TAG'
    description: "Release created using the release-cli. Release '$TAG'\n\nCommits between $PREVIOUS_TAG and $CI_COMMIT_TAG:\n\n$COMMIT_LIST"
    assets:
      links:
        - name: 'my-app.exe'
          url: '$CI_SERVER_URL/$CI_PROJECT_PATH/-/jobs/$JOB_ID/artifacts/download'

This is the error I get;

I did this before as a solution.

etc/gitlab-runner/config.toml ;

[[runners]]
  name = "demo-runner"
  url = "https://gitlabs.........com/"
  id = 24
  token = "J..............cu"
  token_obtained_at = 2023-11-07T14:45:41Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.cache]
    MaxUploadedArchiveSize = 0
  [runners.docker]
    tls_verify = false
    image = "docker:24.0.7"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    shm_size = 0
    network_mtu = 0

Now I did the same thing but the problem was not solved.

I faced the same Error

I tried with unset DOCKER_HOST in script it worked for me.

For Example :-

  script:
    - unset DOCKER_HOST
    - docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
2 Likes

Thank you, i confirm it worked.
@ozgedurgut you could take some time to thank him for his help :sweat_smile:

1 Like

worked like a charm. Thanks a lot.

1 Like

Thank you so much! I was going crazy trying every DNS trick in the book with my shell executor and didn’t make the connection that it had to be related to the env variables.