我有一个 bitbucket 管道,它通过 bazel 运行一组测试,其中一些需要调用 docker 命令(集成测试)。
当我运行此管道时,出现此错误:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
我已经验证的事情:
我的
bitbucket-pipelines.yml
文件具有为带有 bazel 的步骤指定的 docker 服务,如下所示:
pipelines:
default:
- step:
services:
- docker
script:
- bazel test //...
我希望此配置足以使测试正确运行。
事实证明 bazel 不默认将环境变量传递到测试。
修复方法如下:
bazel test --action_env=DOCKER_HOST //...