Docker error during connect: Post http://docker:2375/v1.24/auth
Asked Answered
M

2

5

I am using a docker+machine to run my gitlab ci/cd jobs. My .gitlab-ci.yml looks as such:

image: docker:latest

variables:
  DOCKER_HOST: tcp://docker:2375/
  DOCKER_TLS_CERTDIR: ""

services:
  - docker:19.03.12-dind

stages:
  - build
  - deploy

before_script:
  - mkdir -p ~/.ssh
  - echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
  - chmod 700 ~/.ssh/id_rsa
  - eval "$(ssh-agent -s)"
  - ssh-add ~/.ssh/id_rsa
  - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

build:
  stage: build
  script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD registry.gitlab.com
    - docker info
    - apk add --no-cache py-pip python3-dev libffi-dev openssl-dev gcc libc-dev make
    - export CRYPTOGRAPHY_DONT_BUILD_RUST=1
    - pip install docker-compose

And my config.toml looks like this:

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "Docker Runner"
  url = "https://gitlab.com"
  token = "**"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [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"]
    shm_size = 0

When reaching command: "docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD registry.gitlab.com" GitLab outputs this:

$ [[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
$ docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD registry.gitlab.com
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
error during connect: Post http://docker:2375/v1.24/auth: dial tcp: lookup docker on 172.31.0.2:53: no such host
Cleaning up file based variables 00:01
ERROR: Job failed: exit code 1

I do not understand where the mistake could be... After changing both the ci file and the config.toml.

Meal answered 4/8, 2021 at 15:37 Comment(0)
M
4

I have found the solution for my mistake.

It was simply the docker images between the runner and the gitlab-ci file which were not matching. I simply changed image = docker:19.03.12 in both the yaml and the toml file.

Meal answered 5/8, 2021 at 9:16 Comment(3)
didn't work for me... I am using version 23.0.1Rosebay
@Rosebay make sure you got the privileged and volumes matched inside the config.tomlArchicarp
I fixed it with alias. ThanksRosebay
R
4

I had similar issue and it only worked when I added alias for it:

  services:
    - name: docker:23.0.1-dind
      alias: docker
Rosebay answered 5/4, 2023 at 23:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.