我需要在GitLab CI中运行mocha测试,一些测试需要与docker守护进程进行交互,在容器上运行,运行,创建等。出于{{3中的原因,我试图避免在docker中使用docker }}文章,并与官方this一起尝试他提出的解决方案。
我的.gitlab-ci.yml
具有以下代码。
test-runner:
stage: test
# docker image is based of Alpine Linux - https://wiki.alpinelinux.org
image: docker:stable
tags:
- docker
variables:
GIT_SUBMODULE_STRATEGY: none
before_script:
# expose docker socket to GitLab CI
- docker run -v /var/run/docker.sock:/var/run/docker.sock docker
# install required packages
- apk add nodejs npm git zstd
- git config ....
- git submodule sync --recursive
- git submodule update --init --recursive
script:
- npm ci
- npm run test
我不断收到以下错误,如何解决?
$ docker run -v /var/run/docker.sock:/var/run/docker.sock docker
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
答案 0 :(得分:0)
经过一番研究,我结束了用docker:dind
添加服务字段以暴露套接字的情况。
test-runner:
stage: test
# docker image is based of Alpine Linux - https://wiki.alpinelinux.org
image: docker:stable
services:
- docker:dind
tags:
- docker
variables:
GIT_SUBMODULE_STRATEGY: none
before_script:
# install required packages
- apk add --no-cache bash
- apk add nodejs npm git zstd docker
- git config ...
- git submodule sync --recursive
- git submodule update --init --recursive
script:
- npm ci
- npm run test