Pablo Fernandez
Pablo Fernandez

Reputation: 287740

Can't talk to dind when using google/could-sdk instead of docker:stable in GitLab, why is that?

In GitLab, I have this .gitlab-ci.yml configuration to build a Docker image:

build:
  stage: build
  image: docker:stable
  services:
  - docker:stable-dind
  script:
  - docker build --tag example .

and it works. When I replace the image I'm using to build with google/cloud-sdk:latest:

build:
  stage: build
  image: google/cloud-sdk:latest
  services:
  - docker:stable-dind
  script:
  - docker build --tag example .

I get this error:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

I've seen plenty of articles talking about this but they all offer one of three solutions:

  1. Run the dind service
  2. Define DOCKER_HOST to tcp://localhost:2375/
  3. Define DOCKER_HOST to tcp://docker:2375/

I'm already doing 1, so I tried 2 and 3:

build:
  stage: build
  image: google/cloud-sdk:latest
  services:
  - docker:stable-dind
  variables:
    DOCKER_HOST: tcp://localhost:2375/
  script:
  - docker build --tag example .

Both failed with this error:

Cannot connect to the Docker daemon at tcp://localhost:2375/. Is the docker daemon running?

What am I missing?

Upvotes: 1

Views: 188

Answers (1)

Pablo Fernandez
Pablo Fernandez

Reputation: 287740

tcp://docker:2375 actually works, but when I was trying I had - export DOCKER_HOST=tcp://localhost:2375 in the script from a previous experiment so my changes in the variables section had no effect.

Upvotes: 0

Related Questions