-1

我通过运行创建默认测试角色molecule init scenario default

然后我跑molecule test

GitLab CI 的输出如下:

"stderr": "\u001b[31mERROR: Unable to contact the Docker daemon. Please refer to https://docs.docker.com/config/daemon/ for managing the daemon\u001b[0m\n\u001b[31mERROR: Unable to contact the Docker daemon. Please refer to https://docs.docker.com/config/daemon/ for managing the daemon\u001b[0m",
     "stderr_lines": [
         "\u001b[31mERROR: Unable to contact the Docker daemon. Please refer to https://docs.docker.com/config/daemon/ for managing the daemon\u001b[0m",
         "\u001b[31mERROR: Unable to contact the Docker daemon. Please refer to https://docs.docker.com/config/daemon/ for managing the daemon\u001b[0m"

分子作用如下:

- name: Create Default Role
  command: molecule init scenario default
  args:
    chdir: roles/amazon_cloudwatch_agent

- name: Run Molecule Test
  command: molecule --debug test
  args:
    chdir: roles/amazon_cloudwatch_agent
4

1 回答 1

0

解决方案是重新设计 gitlab-ci.yml 文件,如下所示:

---

image: <insert desired image here> 
services:
  - docker:dind

stages:
  - tests

before_script:
  - docker -v
  - python -V
  - pip install --upgrade pip
  - pip install molecule
  - pip install -U requests==2.5.3

molecule-role-common:
  stage: tests
  tags:
  - molecule
  variables:
    DOCKER_HOST: "tcp://docker:2375"
    PY_COLORS: 1
  script:
    - cd roles/amazon_cloudwatch_agent; molecule init scenario --role-name amazon_cloudwatch_agent
    - ls
    - molecule --debug test

似乎有服务:docker:dind 是让 docker 镜像分子运行与 docker 守护进程连接的关键。

虽然我仍然遇到代理问题,但这已经让我克服了最初遇到的问题。

于 2020-03-26T14:22:06.990 回答