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:

  1. Loads container images into Docker using the specified loader targets
  2. 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:

LoaderSource
oci_loadrules_oci
image_loadrules_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

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
imagesImage 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 labelsoptional[]
yamlA docker_compose_yaml target providing the merged docker-compose configuration.Labelrequired