Building docker image in gitlab-ci using kubernetes runner

Am trying to build a docker image using default template.

This file is a template, and might need editing before it works on your project.

build-master:

Official docker image.

image: docker:latest
stage: build
services:
- docker:dind
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
before_script:
- cat /etc/hosts
- docker login -u “$CI_REGISTRY_USER” -p “$CI_REGISTRY_PASSWORD”
script:
- docker build -t “$CI_REGISTRY_IMAGE” .
- docker push “$CI_REGISTRY_IMAGE”
only:
- master

However when running the same,

  • [new branch] master → origin/master
    Checking out 31bda054 as master…

Skipping Git submodules setup
$ cat /etc/hosts

Kubernetes-managed hosts file.

127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.0.3.24 runner-64-9yy4e-project-3-concurrent-0vvqs9
$ docker login -u “$CI_REGISTRY_USER” -p “$CI_REGISTRY_PASSWORD”
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
error during connect: Post http://docker:2375/v1.40/auth: dial tcp: lookup docker on 10.3.240.10:53: no such host

Note: am using Kubernetes runner from gitlab and the helm has been setup as previledged mode.

Got the same error… pipeline was working file yesterday.

Same issue here, it suddenly stopped working this morning. Non k8s runner though.

I have this at the beginning of my pipeline:

Using docker image sha256:381e1d0bc6ef1b9619690dbc0de477588c4a1f14fc781e31b0123ac6f421c25c for docker:dind ...
Waiting for services to be up and running...

*** WARNING: Service runner-FyVxBitE-project-5-concurrent-0-docker-0 probably didn't start properly.

Health check error:
service "runner-FyVxBitE-project-5-concurrent-0-docker-0-wait-for-service" timeout

Health check container logs:


Service container logs:
2019-08-02T12:14:22.998254366Z time="2019-08-02T12:14:22.998142357Z" level=info msg="Starting up"
2019-08-02T12:14:22.998518193Z time="2019-08-02T12:14:22.998470969Z" level=warning msg="[!] DON'T BIND ON ANY IP ADDRESS WITHOUT setting --tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING [!]"
2019-08-02T12:14:22.999612287Z failed to load listeners: listen tcp: address tcp/2375/: unknown port

Edit: Docker:dind stops working after 12.1.0 update

@aldrine since you’re using k8s, see here: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-in-docker-workflow-with-docker-executor

  # Note that if you're using the Kubernetes executor, the variable should be set to
  # tcp://localhost:2375/ because of how the Kubernetes executor connects services
  # to the job container
  # DOCKER_HOST: tcp://localhost:2375/
  #
  # For non-Kubernetes executors, we use tcp://docker:2375/