Error during connect: Post http://docker:2378/v1.40/auth: dial tcp: lookup docker on 169.254.169.254:53: no such host

I have a very similar problem to the one in this post:

I am running a CI/CD pipeline in Gitlab, and it fails in this job:

build api:
  stage: build
  image: registry.gitlab.com/org/someimage/build-push:latest
  variables:
    DOCKER_HOST: "tcp://docker:2378"
    DOCKER_TLS_CERTDIR: ""
  before_script:
    - echo $GCLOUD_SERVICE_KEY > /gcloud-service-key.json
    - cat /gcloud-service-key.json
    - /google-cloud-sdk/bin/gcloud auth activate-service-account --key-file /gcloud-service-key.json
    - docker login -u _json_key --password-stdin https://us.gcr.io < /gcloud-service-key.json
  script:
    - docker build Backend/ -t gcr.io/$PROJECT_ID/api
    - /google-cloud-sdk/bin/gcloud docker -- docker push gcr.io/$PROJECT_ID/api

It fails when it goes to login in docker

$ docker login -u _json_key --password-stdin https://us.gcr.io < /gcloud-service-key.json

$ docker login -u _json_key --password-stdin https://us.gcr.io < /gcloud-service-key.json

[30] error during connect: Post http://docker:2378/v1.40/auth: dial tcp: lookup docker on 169.254.169.254:53: no such host

I am not using dind, but my image registry.gitlab.com/org/someimage/build-push:latest is built from docker:

FROM docker

RUN apk add --update make ca-certificates openssl python
RUN update-ca-certificates
RUN wget https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz
RUN tar zxvf google-cloud-sdk.tar.gz && ./google-cloud-sdk/install.sh --usage-reporting=false --path-update=true
RUN google-cloud-sdk/bin/gcloud --quiet components update

Does anyone know why I am getting this error? It works perfectly when I run it locally.