Insecure Docker Registry Kubernetes Runner

Docker unable to login to insecure registry

GitLab is running on HTTP, behind a reverse proxy
A Kubernetes cluster (K3S) is configured with gitlab-runner installed from the Gitlab web UI

I’m trying to setup my first docker CI/CD pipeline and am failing because of this message
Get https://git.homelab:5555/v2/: http: server gave HTTP response to HTTPS client

gitlab.rb: registry_external_url 'http://git.homelab:5555'

I’ve already tried --insecure-registry and DOCKER_TLS_CERTDIR=""
From Config when use service docker:dind (#1678) · Issues · GitLab.org / gitlab-runner · GitLab
And Update: Changes to GitLab CI/CD and Docker in Docker with Docker 19.03 | GitLab

Since the runner is on kubernetes and managed by gitlab, I can’t (or don’t know how) to manually configure it to add an insecure-registry entry

I’ve tried hardcoding the $CI_REGISTRY to git.homelab:5555 and http://git.homelab:5555, using = instead of , in the command argument, various older images of docker, with/without the DOCKER_ variables all to the same effect.
Latest .gitlab-ci.yml:

docker-build-master:
  image: docker:latest
  stage: build
  variables:
    DOCKER_HOST: tcp://localhost:2375/
    DOCKER_DRIVER: overlay2
    DOCKER_TLS_CERTDIR: ""

  services:
    - name: docker:dind
      command: ["--insecure-registry", $CI_REGISTRY]
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
  script:
    - docker build --pull -t "$CI_REGISTRY_IMAGE" .
    - docker push "$CI_REGISTRY_IMAGE"

Pipeline logs:

Running with gitlab-runner 13.9.0 (2ebc4dc4)
  on runner-gitlab-runner-686599f449-8ssxm g_NoSgAT
Preparing the "kubernetes" executor
00:00
Using Kubernetes namespace: gitlab-managed-apps
WARNING: Pulling GitLab Runner helper image from Docker Hub. Helper image is migrating to registry.gitlab.com, for more information see https://docs.gitlab.com/runner/configuration/advanced-configuration.html#migrating-helper-image-to-registrygitlabcom
Using Kubernetes executor with image docker:dind ...
Preparing environment
00:09
Waiting for pod gitlab-managed-apps/runner-gnosgat-project-20-concurrent-0hbqkg to be running, status is Pending
Waiting for pod gitlab-managed-apps/runner-gnosgat-project-20-concurrent-0hbqkg to be running, status is Pending
	ContainersNotReady: "containers with unready status: [build helper svc-0]"
	ContainersNotReady: "containers with unready status: [build helper svc-0]"
Waiting for pod gitlab-managed-apps/runner-gnosgat-project-20-concurrent-0hbqkg to be running, status is Pending
	ContainersNotReady: "containers with unready status: [build helper svc-0]"
	ContainersNotReady: "containers with unready status: [build helper svc-0]"
Running on runner-gnosgat-project-20-concurrent-0hbqkg via runner-gitlab-runner-686599f449-8ssxm...
Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/isaacntk/python-cd-test/.git/
Created fresh repository.
Checking out 7004738c as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:00
$ docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
time="2021-04-05T12:46:27Z" level=info msg="Error logging in to endpoint, trying next endpoint" error="Get https://git.homelab:5555/v2/: http: server gave HTTP response to HTTPS client"
Get https://git.homelab:5555/v2/: http: server gave HTTP response to HTTPS client
Cleaning up file based variables
00:00
ERROR: Job failed: command terminated with exit code 1

I’ve search for this question for a long time,and I find solution by use docker login in your runner script(!!mention that not in dind pod), although We have done the registry config in dind pod as well as DOCKER_HOST in runner env.That’s make no sense in my point of view but it works :smiling_face_with_tea

Could you show your code solution above?