docker_compose_binary
Rules
docker_compose_binary
load("@rules_docker_compose//docker_compose:docker_compose_binary.bzl", "docker_compose_binary")
docker_compose_binary(name, images, yaml)
Creates a runnable target for invoking docker-compose with a generated configuration.
This rule consumes a docker_compose_yaml target and produces an executable that:
- Loads container images into Docker using the specified loader targets
- Runs
docker-compose -f <yaml> <args...>forwarding all command-line arguments
Use this rule when you need to interactively manage docker-compose services
(e.g. bazel run :compose -- up -d, bazel run :compose -- down).
Supported image loader types:
| Loader | Source |
|---|---|
| oci_load | rules_oci |
| image_load | rules_img |
Example:
load("@rules_docker_compose//docker_compose:defs.bzl", "docker_compose_binary", "docker_compose_yaml")
load("@rules_oci//oci:defs.bzl", "oci_load")
oci_load(
name = "my_service.load",
image = ":my_service",
repo_tags = ["my-service:latest"],
)
docker_compose_yaml(
name = "compose_yaml",
yamls = ["docker-compose.yaml"],
images = [":my_service.load"],
)
docker_compose_binary(
name = "compose",
yaml = ":compose_yaml",
images = [":my_service.load"],
)
Then run with:
bazel run :compose -- up -d
bazel run :compose -- down
bazel run :compose -- ps
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| images | Image loader targets that provide the container images for the docker-compose services. Each image will be loaded into Docker before docker-compose is invoked. See the rule documentation for supported loader types. | List of labels | optional | [] |
| yaml | A docker_compose_yaml target providing the merged docker-compose configuration. | Label | required |