I have a bitbucket pipeline that runs a set of tests via bazel, some of which need to invoke docker commands (integration tests).
When I run this pipeline, I get this error:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Things I've verified:
DOCKER_HOST
environment variable is being correctly set in the pipelineMy bitbucket-pipelines.yml
file has the docker service specified for the step with bazel like so:
pipelines:
default:
- step:
services:
- docker
script:
- bazel test //...
I would expect this configuration to be sufficient for the tests to run correctly.
It turns out bazel does not pass environment variables through to tests by default.
Here's the fix:
bazel test --action_env=DOCKER_HOST //...