简体   繁体   中英

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?

tcp://docker:2375实际上可以工作,但是当我尝试时- export DOCKER_HOST=tcp://localhost:2375在先前实验的脚本中- export DOCKER_HOST=tcp://localhost:2375 ,所以我对变量部分的更改没有效果。

понимаю, что может быть уже неактуально для автора, но может оказаться полезным для других участников - как я.

решил добавлением монтирования сокета Docker в config.toml:

  [runners.docker]
...        
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/certs/client", "/cache"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM