@zuke/docker-compose

← API reference

`@zuke/docker-compose` — typed Docker Compose task wrappers for Zuke builds.

Symbols

# ComposeProbe type
type ComposeProbe = unknown

Probes whether a candidate Compose invocation is runnable on this host. Receives the binary-and-prefix argv (["docker", "compose"] or ["docker-compose"]) and resolves to true when it works. Injectable so detection can be unit-tested without a real Docker install.

# defaultComposeProbe function
async function defaultComposeProbe(argv: unknown): Promise<boolean>

The default ComposeProbe: run the candidate's version subcommand quietly and treat a zero exit as success. A missing binary resolves to false rather than throwing, so detection can fall through to the next candidate.

# DockerComposeBuildSettings class
class DockerComposeBuildSettings extends DockerComposeSettings

Settings for compose build.

MemberSignatureDoc
noCache noCache(): this Do not use the layer cache (--no-cache).
pull pull(): this Always attempt to pull newer base images (--pull).
buildArg buildArg(key: string, value: string): this Pass a build-time variable (--build-arg KEY=value); repeatable.
services services(...names: string[]): this Restrict to specific services (positional); optional.
# DockerComposeConfigSettings class
class DockerComposeConfigSettings extends DockerComposeSettings

Settings for compose config.

MemberSignatureDoc
quietOutput quietOutput(): this Only validate, printing nothing (-q).
servicesOnly servicesOnly(): this Print the service names only (--services).
volumesOnly volumesOnly(): this Print the volume names only (--volumes).
format format(value: string): this Output format (--format), e.g. yaml or json.
# DockerComposeDownSettings class
class DockerComposeDownSettings extends DockerComposeSettings

Settings for compose down.

MemberSignatureDoc
volumes volumes(): this Also remove named and anonymous volumes (-v).
removeOrphans removeOrphans(): this Remove containers for services no longer defined (--remove-orphans).
rmi rmi(type: string): this Remove images of the given type (--rmi), e.g. all or local.
timeout timeout(seconds: number): this Shutdown timeout in seconds (-t).
# DockerComposeExecSettings class
class DockerComposeExecSettings extends DockerComposeSettings

Settings for compose exec.

MemberSignatureDoc
service service(name: string): this The service whose container to exec into (required).
detach detach(): this Run in the background (-d).
noTty noTty(): this Disable pseudo-TTY allocation (-T).
workdir workdir(path: PathLike): this Working directory inside the container (-w).
envVar envVar(key: string, value: string): this Set an environment variable (-e KEY=value); repeatable.
commandArgs commandArgs(...args: Array<string | number>): this The command and arguments to execute.
# DockerComposeLogsSettings class
class DockerComposeLogsSettings extends DockerComposeSettings

Settings for compose logs.

MemberSignatureDoc
follow follow(): this Stream new log output (-f).
timestamps timestamps(): this Prefix each line with a timestamp (-t).
tail tail(lines: number | all): this Show only the last N lines, or all (--tail).
services services(...names: string[]): this Restrict to specific services (positional); optional.
# DockerComposePsSettings class
class DockerComposePsSettings extends DockerComposeSettings

Settings for compose ps.

MemberSignatureDoc
all all(): this Show stopped containers too (-a).
quietOutput quietOutput(): this Only show container IDs (-q).
servicesOnly servicesOnly(): this Display services instead of containers (--services).
services services(...names: string[]): this Restrict to specific services (positional); optional.
# DockerComposePullSettings class
class DockerComposePullSettings extends DockerComposeSettings

Settings for compose pull.

MemberSignatureDoc
ignorePullFailures ignorePullFailures(): this Continue past services whose pull fails (--ignore-pull-failures).
quietOutput quietOutput(): this Pull without printing progress (-q).
services services(...names: string[]): this Restrict to specific services (positional); optional.
# DockerComposePushSettings class
class DockerComposePushSettings extends DockerComposeSettings

Settings for compose push.

MemberSignatureDoc
ignorePushFailures ignorePushFailures(): this Continue past services whose push fails (--ignore-push-failures).
services services(...names: string[]): this Restrict to specific services (positional); optional.
# DockerComposeRestartSettings class
class DockerComposeRestartSettings extends DockerComposeSettings

Settings for compose restart.

MemberSignatureDoc
timeout timeout(seconds: number): this Restart timeout in seconds (-t).
services services(...names: string[]): this Restrict to specific services (positional); optional.
# DockerComposeRmSettings class
class DockerComposeRmSettings extends DockerComposeSettings

Settings for compose rm.

MemberSignatureDoc
force force(): this Do not prompt for confirmation (-f).
stop stop(): this Stop the containers first if needed (-s).
volumes volumes(): this Also remove anonymous volumes (-v).
services services(...names: string[]): this Restrict to specific services (positional); optional.
# DockerComposeRunSettings class
class DockerComposeRunSettings extends DockerComposeSettings

Settings for compose run.

MemberSignatureDoc
service service(name: string): this The service to run (required).
rm rm(): this Remove the container after it exits (--rm).
detach detach(): this Run in the background (-d).
noDeps noDeps(): this Do not start linked services (--no-deps).
name name(value: string): this Assign a container name (--name).
envVar envVar(key: string, value: string): this Set an environment variable (-e KEY=value); repeatable.
commandArgs commandArgs(...args: Array<string | number>): this The command and arguments to run inside the container.
# DockerComposeSettings class
class DockerComposeSettings extends ToolSettings

Base for all Compose subcommand settings. Holds the invocation prefix (docker compose vs docker-compose) and the global options that precede every subcommand (-f, -p, --profile, …), and resolves the prefix at run time unless it was pinned with usePlugin/useStandalone.

MemberSignatureDoc
file file(path: PathLike): this Add a Compose file (-f); repeatable, order-significant.
projectName projectName(name: string): this Set the project name (-p).
profile profile(name: string): this Enable a service profile (--profile); repeatable.
projectDirectory projectDirectory(path: PathLike): this Set the project working directory (--project-directory).
envFile envFile(path: PathLike): this Load environment from a file (--env-file).
usePlugin usePlugin(): this Force the v2 plugin form (docker compose) and skip detection.
useStandalone useStandalone(): this Force the v1 standalone form (docker-compose) and skip detection.
run run(): Promise<CommandOutput> Resolve the invocation prefix (unless pinned) and run, so the same build works against either the v2 plugin or the v1 standalone binary.
# DockerComposeStartSettings class
class DockerComposeStartSettings extends DockerComposeSettings

Settings for compose start.

MemberSignatureDoc
services services(...names: string[]): this Restrict to specific services (positional); optional.
# DockerComposeStopSettings class
class DockerComposeStopSettings extends DockerComposeSettings

Settings for compose stop.

MemberSignatureDoc
timeout timeout(seconds: number): this Shutdown timeout in seconds (-t).
services services(...names: string[]): this Restrict to specific services (positional); optional.
# DockerComposeTasks const
const DockerComposeTasks: DockerComposeTasksApi

Typed task functions for Docker Compose (docker compose/docker-compose).

# DockerComposeTasksApi interface
interface DockerComposeTasksApi

The shape of DockerComposeTasks.

MemberSignatureDoc
up up(configure?: Configure<DockerComposeUpSettings>): Promise<CommandOutput> Create and start services: compose up.
down down(configure?: Configure<DockerComposeDownSettings>): Promise<CommandOutput> Stop and remove services: compose down.
build build(configure?: Configure<DockerComposeBuildSettings>): Promise<CommandOutput> Build service images: compose build.
pull pull(configure?: Configure<DockerComposePullSettings>): Promise<CommandOutput> Pull service images: compose pull.
push push(configure?: Configure<DockerComposePushSettings>): Promise<CommandOutput> Push service images: compose push.
run run(configure?: Configure<DockerComposeRunSettings>): Promise<CommandOutput> Run a one-off command: compose run.
exec exec(configure?: Configure<DockerComposeExecSettings>): Promise<CommandOutput> Exec into a running service: compose exec.
logs logs(configure?: Configure<DockerComposeLogsSettings>): Promise<CommandOutput> View service logs: compose logs.
ps ps(configure?: Configure<DockerComposePsSettings>): Promise<CommandOutput> List containers: compose ps.
config config(configure?: Configure<DockerComposeConfigSettings>): Promise<CommandOutput> Render the resolved configuration: compose config.
start start(configure?: Configure<DockerComposeStartSettings>): Promise<CommandOutput> Start existing services: compose start.
stop stop(configure?: Configure<DockerComposeStopSettings>): Promise<CommandOutput> Stop running services: compose stop.
restart restart(configure?: Configure<DockerComposeRestartSettings>): Promise<CommandOutput> Restart services: compose restart.
rm rm(configure?: Configure<DockerComposeRmSettings>): Promise<CommandOutput> Remove stopped service containers: compose rm.
# DockerComposeUpSettings class
class DockerComposeUpSettings extends DockerComposeSettings

Settings for compose up.

MemberSignatureDoc
detach detach(): this Run in the background (-d).
build build(): this Build images before starting (--build).
forceRecreate forceRecreate(): this Recreate containers even if unchanged (--force-recreate).
removeOrphans removeOrphans(): this Remove containers for services no longer defined (--remove-orphans).
wait wait(): this Wait until services are running/healthy (--wait).
abortOnContainerExit abortOnContainerExit(): this Stop all containers if any container stops (--abort-on-container-exit).
exitCodeFrom exitCodeFrom(service: string): this Exit with this service's container's exit code (--exit-code-from).
scale scale(service: string, instances: number): this Scale a service to N instances (--scale service=N); repeatable.
services services(...names: string[]): this Restrict to specific services (positional); optional.
# resetComposeInvocationCache_ function
function resetComposeInvocationCache_(): void

Clear the cached Compose invocation so the next resolveComposeInvocation re-detects. Internal test seam — the trailing underscore signals it is not part of the stable public API.

# resolveComposeInvocation function
function resolveComposeInvocation(probe?: ComposeProbe): Promise<string[]>

Resolve how Docker Compose is invoked on this host: ["docker", "compose"] for the v2 plugin or ["docker-compose"] for the v1 standalone binary. The v2 plugin is preferred; if neither is runnable a ToolNotFoundError is raised. The result is cached after the first successful detection (a failed detection is not cached, so a later call retries). Pass a custom ComposeProbe to override how candidates are tested.