Build docker image in Gitlab CI fails

Today I wanted to create docker image using Gitlab CI with the following config:

tages:
  - build

build-docker:
  stage: build
  only:
    - docker
  image: docker:stable
  variables:
    CONTAINER_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH
    DOCKER_HOST: tcp://docker:2375
    DOCKER_DRIVER: overlay2

  before_script:
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY

  script:
    - docker pull $CONTAINER_IMAGE:latest || true
    - docker build --cache-from $CONTAINER_IMAGE:latest --tag $CONTAINER_IMAGE:$CI_COMMIT_SHA --tag $CONTAINER_IMAGE:latest .
    - docker push $CONTAINER_IMAGE:$CI_COMMIT_SHA
    - docker push $CONTAINER_IMAGE:latest

But I got following error in build script:

Running on runner-fa6cab46-project-10671117-concurrent-0 via runner-fa6cab46-srm-1551536467-c325143f...
Cloning repository...
Cloning into '/builds/myrepo'...
Checking out e2220457 as docker...
Skipping Git submodules setup
$ docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
error during connect: Post http://docker:2375/v1.39/auth: dial tcp: lookup docker on 169.254.169.254:53: no such host
ERROR: Job failed: exit code 1

Is it temporary issue? or my misconfiguration? Please help.

Hey there,

You may want to reference the GitHub issue linked below, as it pertains to the same error you are encountering. This seems to indicate its more of an issue with the machine that’s being utilized as the executor rather than the CI implementation itself.

Error while pushing images to registry: `dial tcp: lookup registry on 192.168.65.1:53: no such host.