Error Docker in Docker inside Gitlab Runner on Kubernetes

Hello,

I have been using Dind to build my images and push them to my private repository. Now strangely it started to give me error. Note that system was idle (no commits or tweaks any kind) about for a month. When i came back my runner is throwing error.

I am using nginx ingress controller. No proxies of any kind on network.

This error only occurs on gitlab-runner spawned build pod. Host machine successfully gets to docker.io

Running with gitlab-runner 12.0.1 (0e5417a3)
  on gitlab-runner-gitlab-runner-7bc4c4cdff-xmsn2 xamPjLd9
Using Kubernetes namespace: gitlab-managed-apps
Using Kubernetes executor with image docker:git ...
Waiting for pod gitlab-managed-apps/runner-xampjld9-project-3-concurrent-04wq2w to be running, status is Pending
Waiting for pod gitlab-managed-apps/runner-xampjld9-project-3-concurrent-04wq2w to be running, status is Pending
Running on runner-xampjld9-project-3-concurrent-04wq2w via gitlab-runner-gitlab-runner-7bc4c4cdff-xmsn2...
Fetching changes...
Initialized empty Git repository in /builds/[MASKED]/pts-server/.git/
Created fresh repository.
warning: redirecting to https://git.myserver.com:443/[MASKED]/pts-server.git/
From http://git.myserver.com/[MASKED]/pts-server
 * [new branch]      master     -> origin/master
Checking out d13db1b4 as master...

Skipping Git submodules setup
$ docker login -u "$CI_USERNAME" -p "$CI_PASSWORD" https://registry.myserver.com
WARNING! Using --password via the CLI is insecure. Use --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
$ export DOCKER_HOST="tcp://localhost:2375"
$ docker pull $CI_REGISTRY_IMAGE:latest || true
latest: Pulling from muhammed/pts-server
9cc2ad81d40d: Pulling fs layer
e6cb98e32a52: Pulling fs layer
....
54532a0e6ebd: Pull complete
dda652560307: Pull complete
Digest: sha256:8b03ed24aebbd1f1fd1ccfe9fa0321776b93c5b6752d609582a825fe22724605
Status: Downloaded newer image for registry.myserver.com/muhammed/pts-server:latest
$ docker build --cache-from $CI_REGISTRY_IMAGE:latest -t "$CI_REGISTRY_IMAGE:latest" .
Sending build context to Docker daemon   28.5MB

Step 1/8 : FROM node:12.9
Get https://registry-1.docker.io/v2/: x509: certificate is valid for NGINXIngressController, not registry-1.docker.io
ERROR: Job failed: command terminated with exit code 1

My gitlab-ci.yml file is a follows

image: docker:git
services:
  - docker:dind

stages:
  - build
  - test
  - deploy
  

build:
  before_script:
    - docker login -u "$CI_USERNAME" -p "$CI_PASSWORD" https://registry.myserver.com
  stage: build
  script:
    - export DOCKER_HOST="tcp://localhost:2375"
    - docker pull $CI_REGISTRY_IMAGE:latest || true
    - docker build --cache-from $CI_REGISTRY_IMAGE:latest -t "$CI_REGISTRY_IMAGE:latest" .
    - docker push "$CI_REGISTRY_IMAGE:latest"
  only:
    - master
    
test:
  stage: test
  script:
    - echo "Testing"
  
deploy:
  stage: deploy
  image: dtzar/helm-kubectl
  script:
    - kubectl delete deploy pts-server -n gitlab
    - kubectl apply -f deployment.yml
    - kubectl apply -f service.yml
  only:
    - master
  when: manual

I have insalled gitlab runner via helm

gitlabUrl: 'https://git.myserver.com/'
runnerRegistrationToken: Lb-XXXXXXXToken
concurrent: 10
checkInterval: 30
rbac:
    create: true
    clusterWideAccess: true
runners:
    image: 'ubuntu:18.04'                   
    privileged: true
    builds:
        cpuRequests: 100m
        memoryRequests: 128Mi
    services:
        cpuRequests: 100m
        memoryRequests: 128Mi
    helpers:
        cpuRequests: 100m
        memoryRequests: 128Mi
Edited by Muhammed