@zuke/docker-compose
`@zuke/docker-compose` — typed Docker Compose task wrappers for Zuke builds.
@zuke/docker-compose on JSR ↗ 21 symbols
Symbols
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.
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.
class DockerComposeBuildSettings extends DockerComposeSettings Settings for compose build.
| Member | Signature | Doc |
|---|---|---|
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. |
class DockerComposeConfigSettings extends DockerComposeSettings Settings for compose config.
| Member | Signature | Doc |
|---|---|---|
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. |
class DockerComposeDownSettings extends DockerComposeSettings Settings for compose down.
| Member | Signature | Doc |
|---|---|---|
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). |
class DockerComposeExecSettings extends DockerComposeSettings Settings for compose exec.
| Member | Signature | Doc |
|---|---|---|
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. |
class DockerComposeLogsSettings extends DockerComposeSettings Settings for compose logs.
| Member | Signature | Doc |
|---|---|---|
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. |
class DockerComposePsSettings extends DockerComposeSettings Settings for compose ps.
| Member | Signature | Doc |
|---|---|---|
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. |
class DockerComposePullSettings extends DockerComposeSettings Settings for compose pull.
| Member | Signature | Doc |
|---|---|---|
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. |
class DockerComposePushSettings extends DockerComposeSettings Settings for compose push.
| Member | Signature | Doc |
|---|---|---|
ignorePushFailures | ignorePushFailures(): this | Continue past services whose push fails (--ignore-push-failures). |
services | services(...names: string[]): this | Restrict to specific services (positional); optional. |
class DockerComposeRestartSettings extends DockerComposeSettings Settings for compose restart.
| Member | Signature | Doc |
|---|---|---|
timeout | timeout(seconds: number): this | Restart timeout in seconds (-t). |
services | services(...names: string[]): this | Restrict to specific services (positional); optional. |
class DockerComposeRmSettings extends DockerComposeSettings Settings for compose rm.
| Member | Signature | Doc |
|---|---|---|
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. |
class DockerComposeRunSettings extends DockerComposeSettings Settings for compose run.
| Member | Signature | Doc |
|---|---|---|
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. |
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.
| Member | Signature | Doc |
|---|---|---|
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. |
class DockerComposeStartSettings extends DockerComposeSettings Settings for compose start.
| Member | Signature | Doc |
|---|---|---|
services | services(...names: string[]): this | Restrict to specific services (positional); optional. |
class DockerComposeStopSettings extends DockerComposeSettings Settings for compose stop.
| Member | Signature | Doc |
|---|---|---|
timeout | timeout(seconds: number): this | Shutdown timeout in seconds (-t). |
services | services(...names: string[]): this | Restrict to specific services (positional); optional. |
const DockerComposeTasks: DockerComposeTasksApi Typed task functions for Docker Compose (docker compose/docker-compose).
interface DockerComposeTasksApi The shape of DockerComposeTasks.
| Member | Signature | Doc |
|---|---|---|
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. |
class DockerComposeUpSettings extends DockerComposeSettings Settings for compose up.
| Member | Signature | Doc |
|---|---|---|
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. |
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.
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.