container_run_and_commit_layer fails with: docker not found

Viewed 454

I have a problem when running container_run_and_commit_layer, the error message I get is

docker not found; do you need to manually configure the docker toolchain?

from what I see this is related to DOCKER variable not set:

# Resolve the docker tool path
DOCKER=""
DOCKER_FLAGS=""

if [[ -z "$DOCKER" ]]; then
    echo >&2 "error: docker not found; do you need to manually configure the docker toolchain?"
    exit 1
fi

I'm calling container_repositories() in my workspace file, am I missing something?

1 Answers

That rule requires Docker to be installed. By default, it expects to find docker via $PATH. When it doesn't, you get that error.

The Setup section of the rules_docker documentation lists all the optional tools, and shows how to set custom paths to them. Some of the rules_docker rules don't need any of those, so they'll work fine. The rules which do need those tools give errors like this when run when the given tools aren't installed.

If you install docker now, you might have to bazel clean --expunge after installing it to ensure the repository rule is evaluated again.

Related