【问题标题】:How to run circleci locally on macOS with a job that uses Docker?如何通过使用 Docker 的作业在 macOS 上本地运行 circleci?
【发布时间】:2020-02-25 00:21:54
【问题描述】:

我在尝试构建 docker 映像时尝试在 macOS 上本地运行 circleci build 时遇到了问题。

.config 文件示例

version: 2
jobs:
  build:
    docker:
      - image: cimg/base:2020.01
    steps:
      - setup_remote_docker
      - run:
          name: Run Docker
          command: docker run cimg/base:2020.01 echo "hello"

运行后circleci build

failed to dial gRPC: cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial unix /var/run/docker.sock: connect: permission denied

我查看了几个类似的问题,例如 this one,但他们的解决方案都不起作用。

【问题讨论】:

    标签: docker circleci


    【解决方案1】:

    我能够调整解决方案 here 以使用 circleci。

    只需将命令sudo chown circleci:circleci /var/run/docker.sock 添加到您的圈子配置中。

    所以它看起来像:

    version: 2
    jobs:
      build:
        docker:
          - image: cimg/base:2020.01
        steps:
          - setup_remote_docker
          - run: if [ -e /var/run/docker.sock ]; then sudo chown circleci:circleci /var/run/docker.sock; fi
          - run:
              name: Run Docker
              command: docker run cimg/base:2020.01 echo "hello"
    

    结果

    ====>> Run Docker
      #!/bin/bash -eo pipefail
    docker run cimg/base:2020.01 echo "hello"
    hello
    Success!
    

    【讨论】:

      猜你喜欢
      • 2021-11-14
      • 1970-01-01
      • 2021-03-29
      • 2019-07-26
      • 1970-01-01
      • 2019-10-16
      • 2019-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多