'Is it possible to run a command in a Docker image as a test in Bazel?

I would like to run a command inside a container to test that it works. It should be invoked by bazel test.

Something like this:

container_test(
  image = "//:my_image"
  test_command = "exit 1"
)

I noticed this: https://github.com/bazelbuild/rules_docker/blob/master/contrib/test.bzl#L125

However it isn't documented.

How should I approach this in Bazel?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source