zuke.tools.docker_compose
@zuke/docker-compose 1.3.1: @zuke/docker-compose — typed Docker Compose task wrappers for Zuke builds.
zuke on PyPI ↗ 34 symbols
Symbols
class DockerComposeBuildSettings(DockerComposeSettings) Settings for compose build.
-
no_cache() -> SelfDo not use the layer cache (
--no-cache). -
pull() -> SelfAlways attempt to pull newer base images (
--pull). -
build_arg(key: str, value: str) -> SelfPass a build-time variable (
--build-arg KEY=value); repeatable. -
services(*names: str) -> SelfRestrict to specific services (positional); optional.
class DockerComposeCommitSettings(DockerComposeSettings) Settings for compose commit.
-
service(name: str) -> SelfThe service whose container to commit (required).
-
reference(value: str) -> SelfThe image reference to create, e.g.
my-app:test. -
author(value: str) -> SelfImage author (
--author). -
message(value: str) -> SelfCommit message (
--message). -
change(*instructions: str) -> SelfApply a Dockerfile instruction to the created image (
--change). -
index(value: float) -> SelfPick the replica to commit when the service has several (
--index). -
no_pause() -> SelfLeave the container running during the commit (
--pause=false). Compose pauses it by default so the filesystem cannot change mid-capture; turning that off trades a consistent image for uninterrupted service.
class DockerComposeConfigSettings(DockerComposeSettings) Settings for compose config.
-
quiet_output() -> SelfOnly validate, printing nothing (
-q). -
services_only() -> SelfPrint the service names only (
--services). -
volumes_only() -> SelfPrint the volume names only (
--volumes). -
format(value: str) -> SelfOutput format (
--format), e.g.yamlorjson.
class DockerComposeCpSettings(DockerComposeSettings) Settings for compose cp.
Compose copies between a service container and the local filesystem, so exactly one side names a service. Naming both or neither is refused rather than handed to Compose as a path it cannot resolve.
-
from_service(service: str, path: str) -> SelfCopy out of
serviceatpath(SERVICE:PATH). -
from_local(path: str) -> SelfCopy out of a local path.
-
to_service(service: str, path: str) -> SelfCopy into
serviceatpath(SERVICE:PATH). -
to_local(path: str) -> SelfCopy into a local path.
-
index(value: float) -> SelfPick the replica to copy from when the service has several (
--index). -
all() -> SelfInclude containers created by
compose run(--all). -
archive() -> SelfPreserve uid/gid information (
--archive). -
follow_link() -> SelfFollow symbolic links in the source path (
--follow-link).
class DockerComposeCreateSettings(DockerComposeSettings) Settings for compose create.
-
services(*names: str) -> SelfRestrict creation to these services.
-
build() -> SelfBuild images before creating containers (
--build). -
no_build() -> SelfNever build, whatever the policy says (
--no-build). -
force_recreate() -> SelfRecreate containers even when their configuration has not changed (
--force-recreate). -
no_recreate() -> SelfLeave existing containers in place (
--no-recreate). -
remove_orphans() -> SelfRemove containers for services no longer in the file (
--remove-orphans). -
quiet_pull() -> SelfPull without progress output (
--quiet-pull). -
pull(policy: Literal['always', 'missing', 'never']) -> SelfWhen to pull images before creating (
--pull). -
scale(service: str, replicas: float) -> SelfCreate
replicascontainers forservice(--scale). -
yes() -> SelfAnswer every prompt affirmatively (
--yes), so an unattended run cannot stall.
class DockerComposeDownSettings(DockerComposeSettings) Settings for compose down.
-
volumes() -> SelfAlso remove named and anonymous volumes (
-v). -
remove_orphans() -> SelfRemove containers for services no longer defined (
--remove-orphans). -
rmi(type_: str) -> SelfRemove images of the given type (
--rmi), e.g.allorlocal. -
timeout(seconds: float) -> SelfShutdown timeout in seconds (
-t).
class DockerComposeEventsSettings(DockerComposeSettings) Settings for compose events.
-
services(*names: str) -> SelfRestrict the stream to these services.
-
json() -> SelfEmit each event as a JSON object (
--json). -
since(timestamp: str) -> SelfInclude events since a timestamp (
--since). -
until(timestamp: str) -> SelfStop streaming at a timestamp (
--until). Without it the command streams until interrupted, so a build target that awaits it blocks — bound the run with this or with.killAfter(ms).
class DockerComposeExecSettings(DockerComposeSettings) Settings for compose exec.
-
service(name: str) -> SelfThe service whose container to exec into (required).
-
detach() -> SelfRun in the background (
-d). -
no_tty() -> SelfDisable pseudo-TTY allocation (
-T). -
workdir(path: str) -> SelfWorking directory inside the container (
-w). -
env_var(key: str, value: str) -> SelfSet an environment variable (
-e KEY=value); repeatable. -
command_args(*args: str | float) -> SelfThe command and arguments to execute.
class DockerComposeExportSettings(DockerComposeSettings) Settings for compose export.
-
service(name: str) -> SelfThe service whose container filesystem to export (required).
-
output(path: str) -> SelfWrite the tar archive to a file (
--output) instead of stdout. Prefer it: a tar stream captured as the command's stdout goes through Zuke's output buffer, which is text-shaped and size-capped. -
index(value: float) -> SelfPick the replica to export when the service has several (
--index).
class DockerComposeImagesSettings(DockerComposeListingSettings) Settings for compose images.
-
services(*names: str) -> SelfRestrict the listing to these services.
class DockerComposeKillSettings(DockerComposeSettings) Settings for compose kill.
-
services(*names: str) -> SelfRestrict the kill to these services.
-
signal(name: str) -> SelfThe signal to send (
--signal),SIGKILLby default. SendSIGTERMto let a service run its shutdown path —killskips the grace periodstopgives it. -
remove_orphans() -> SelfRemove containers for services no longer in the file (
--remove-orphans).
class DockerComposeListingSettings(DockerComposeSettings) Shared by the listing subcommands that accept --format and --quiet.
--format json is what makes these readable by a build rather than by a person, so the convenience json spells it rather than leaving the caller to remember the value.
-
format(value: str) -> SelfFormat the output (
--format), e.g.tableorjson. -
json() -> SelfEmit JSON (
--format json). -
quiet_output() -> SelfPrint only identifiers or names (
--quiet).
class DockerComposeLogsSettings(DockerComposeSettings) Settings for compose logs.
-
follow() -> SelfStream new log output (
-f). -
timestamps() -> SelfPrefix each line with a timestamp (
-t). -
tail(lines: Literal['all'] | float) -> SelfShow only the last N lines, or
all(--tail). -
services(*names: str) -> SelfRestrict to specific services (positional); optional.
class DockerComposeLsSettings(DockerComposeListingSettings) Settings for compose ls, which lists Compose projects rather than services.
-
all() -> SelfInclude stopped projects (
--all). -
filter(expression: str) -> SelfFilter the listing (
--filter), e.g.name=my-project.
class DockerComposePauseSettings(DockerComposeServiceListSettings) Settings for compose pause.
class DockerComposePortSettings(DockerComposeSettings) Settings for compose port, which prints the host address a service's container port was published on.
-
service(name: str) -> SelfThe service to ask about (required).
-
private_port(port: float) -> SelfThe container-side port to look up (required).
-
protocol(value: Literal['tcp', 'udp']) -> SelfThe protocol of the binding (
--protocol),tcpby default. -
index(value: float) -> SelfPick the replica to ask when the service has several (
--index).
class DockerComposePsSettings(DockerComposeSettings) Settings for compose ps.
-
all() -> SelfShow stopped containers too (
-a). -
quiet_output() -> SelfOnly show container IDs (
-q). -
services_only() -> SelfDisplay services instead of containers (
--services). -
format(value: str) -> SelfOutput format (
--format):table,json, or a Go template such as{{.Image}}, which prints one line per container. -
services(*names: str) -> SelfRestrict to specific services (positional); optional.
class DockerComposePullSettings(DockerComposeSettings) Settings for compose pull.
-
ignore_pull_failures() -> SelfContinue past services whose pull fails (
--ignore-pull-failures). -
policy(value: Literal['always', 'missing', 'never']) -> SelfWhich images to pull (
--policy):missingskips an image already present locally — so a locally built image is not looked up in a registry — andalwaysfetches every one. -
quiet_output() -> SelfPull without printing progress (
-q). -
services(*names: str) -> SelfRestrict to specific services (positional); optional.
class DockerComposePushSettings(DockerComposeSettings) Settings for compose push.
-
ignore_push_failures() -> SelfContinue past services whose push fails (
--ignore-push-failures). -
services(*names: str) -> SelfRestrict to specific services (positional); optional.
class DockerComposeRestartSettings(DockerComposeSettings) Settings for compose restart.
-
timeout(seconds: float) -> SelfRestart timeout in seconds (
-t). -
services(*names: str) -> SelfRestrict to specific services (positional); optional.
class DockerComposeRmSettings(DockerComposeSettings) Settings for compose rm.
-
force() -> SelfDo not prompt for confirmation (
-f). -
stop() -> SelfStop the containers first if needed (
-s). -
volumes() -> SelfAlso remove anonymous volumes (
-v). -
services(*names: str) -> SelfRestrict to specific services (positional); optional.
class DockerComposeRunSettings(DockerComposeSettings) Settings for compose run.
-
service(name: str) -> SelfThe service to run (required).
-
rm() -> SelfRemove the container after it exits (
--rm). -
detach() -> SelfRun in the background (
-d). -
no_deps() -> SelfDo not start linked services (
--no-deps). -
name(value: str) -> SelfAssign a container name (
--name). -
env_var(key: str, value: str) -> SelfSet an environment variable (
-e KEY=value); repeatable. -
command_args(*args: str | float) -> SelfThe command and arguments to run inside the container.
class DockerComposeScaleSettings(DockerComposeSettings) Settings for compose scale.
-
scale(service: str, replicas: float) -> SelfScale
servicetoreplicasinstances; repeatable (required). -
no_deps() -> SelfDo not start linked services (
--no-deps).
class DockerComposeServiceListSettings(DockerComposeSettings) Settings shared by compose pause and compose unpause, which take only a service list.
-
services(*names: str) -> SelfRestrict the command to these services.
class DockerComposeSettings(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.
-
file(path: str) -> SelfAdd a Compose file (
-f); repeatable, order-significant. -
project_name(name: str) -> SelfSet the project name (
-p). -
profile(name: str) -> SelfEnable a service profile (
--profile); repeatable. -
project_directory(path: str) -> SelfSet the project working directory (
--project-directory). -
env_file(path: str) -> SelfLoad environment from a file (
--env-file). -
use_plugin() -> SelfForce the v2 plugin form (
docker compose) and skip detection. -
use_standalone() -> SelfForce the v1 standalone form (
docker-compose) and skip detection.
class DockerComposeStartSettings(DockerComposeSettings) Settings for compose start.
-
services(*names: str) -> SelfRestrict to specific services (positional); optional.
class DockerComposeStopSettings(DockerComposeSettings) Settings for compose stop.
-
timeout(seconds: float) -> SelfShutdown timeout in seconds (
-t). -
services(*names: str) -> SelfRestrict to specific services (positional); optional.
class DockerComposeTasks Typed task functions for Docker Compose (docker compose/docker-compose).
-
static async up(ctx: ServiceContext, configure: Callable[[DockerComposeUpSettings], DockerComposeUpSettings] | None=None) -> ExecResultCreate and start services:
compose up. -
static async down(ctx: ServiceContext, configure: Callable[[DockerComposeDownSettings], DockerComposeDownSettings] | None=None) -> ExecResultStop and remove services:
compose down. -
static async build(ctx: ServiceContext, configure: Callable[[DockerComposeBuildSettings], DockerComposeBuildSettings] | None=None) -> ExecResultBuild service images:
compose build. -
static async pull(ctx: ServiceContext, configure: Callable[[DockerComposePullSettings], DockerComposePullSettings] | None=None) -> ExecResultPull service images:
compose pull. -
static async push(ctx: ServiceContext, configure: Callable[[DockerComposePushSettings], DockerComposePushSettings] | None=None) -> ExecResultPush service images:
compose push. -
static async run(ctx: ServiceContext, configure: Callable[[DockerComposeRunSettings], DockerComposeRunSettings] | None=None) -> ExecResultRun a one-off command:
compose run. -
static async exec(ctx: ServiceContext, configure: Callable[[DockerComposeExecSettings], DockerComposeExecSettings] | None=None) -> ExecResultExec into a running service:
compose exec. -
static async logs(ctx: ServiceContext, configure: Callable[[DockerComposeLogsSettings], DockerComposeLogsSettings] | None=None) -> ExecResultView service logs:
compose logs. -
static async ps(ctx: ServiceContext, configure: Callable[[DockerComposePsSettings], DockerComposePsSettings] | None=None) -> ExecResultList containers:
compose ps. -
static async config(ctx: ServiceContext, configure: Callable[[DockerComposeConfigSettings], DockerComposeConfigSettings] | None=None) -> ExecResultRender the resolved configuration:
compose config. -
static async start(ctx: ServiceContext, configure: Callable[[DockerComposeStartSettings], DockerComposeStartSettings] | None=None) -> ExecResultStart existing services:
compose start. -
static async stop(ctx: ServiceContext, configure: Callable[[DockerComposeStopSettings], DockerComposeStopSettings] | None=None) -> ExecResultStop running services:
compose stop. -
static async restart(ctx: ServiceContext, configure: Callable[[DockerComposeRestartSettings], DockerComposeRestartSettings] | None=None) -> ExecResultRestart services:
compose restart. -
static async rm(ctx: ServiceContext, configure: Callable[[DockerComposeRmSettings], DockerComposeRmSettings] | None=None) -> ExecResultRemove stopped service containers:
compose rm. -
static async create(ctx: ServiceContext, configure: Callable[[DockerComposeCreateSettings], DockerComposeCreateSettings] | None=None) -> ExecResultCreate containers without starting them:
compose create. -
static async kill(ctx: ServiceContext, configure: Callable[[DockerComposeKillSettings], DockerComposeKillSettings] | None=None) -> ExecResultForce-stop service containers:
compose kill. -
static async pause(ctx: ServiceContext, configure: Callable[[DockerComposePauseSettings], DockerComposePauseSettings] | None=None) -> ExecResultPause services:
compose pause. -
static async unpause(ctx: ServiceContext, configure: Callable[[DockerComposeUnpauseSettings], DockerComposeUnpauseSettings] | None=None) -> ExecResultResume paused services:
compose unpause. -
static async scale(ctx: ServiceContext, configure: Callable[[DockerComposeScaleSettings], DockerComposeScaleSettings] | None=None) -> ExecResultSet service replica counts:
compose scale. -
static async wait(ctx: ServiceContext, configure: Callable[[DockerComposeWaitSettings], DockerComposeWaitSettings] | None=None) -> ExecResultBlock until services stop:
compose wait. Keeps the ordinary contract — a non-zero container status fails the target. Use DockerComposeTasksApi.waitExitCode when the status is the answer rather than a failure. -
static async cp(ctx: ServiceContext, configure: Callable[[DockerComposeCpSettings], DockerComposeCpSettings] | None=None) -> ExecResultCopy between a service container and the local filesystem:
compose cp. -
static async top(ctx: ServiceContext, configure: Callable[[DockerComposeTopSettings], DockerComposeTopSettings] | None=None) -> ExecResultShow running processes:
compose top. -
static async export(ctx: ServiceContext, configure: Callable[[DockerComposeExportSettings], DockerComposeExportSettings] | None=None) -> ExecResultExport a container filesystem as a tar archive:
compose export. -
static async commit(ctx: ServiceContext, configure: Callable[[DockerComposeCommitSettings], DockerComposeCommitSettings] | None=None) -> ExecResultCreate an image from a container:
compose commit. -
static async images(ctx: ServiceContext, configure: Callable[[DockerComposeImagesSettings], DockerComposeImagesSettings] | None=None) -> ExecResultList the images the containers use:
compose images. -
static async volumes(ctx: ServiceContext, configure: Callable[[DockerComposeVolumesSettings], DockerComposeVolumesSettings] | None=None) -> ExecResultList the project's volumes:
compose volumes. -
static async ls(ctx: ServiceContext, configure: Callable[[DockerComposeLsSettings], DockerComposeLsSettings] | None=None) -> ExecResultList Compose projects:
compose ls. -
static async version(ctx: ServiceContext, configure: Callable[[DockerComposeVersionSettings], DockerComposeVersionSettings] | None=None) -> ExecResultReport the Compose version:
compose version. -
static async port(ctx: ServiceContext, configure: Callable[[DockerComposePortSettings], DockerComposePortSettings] | None=None) -> ExecResultPrint a published port binding:
compose port. -
static async events(ctx: ServiceContext, configure: Callable[[DockerComposeEventsSettings], DockerComposeEventsSettings] | None=None) -> ExecResultStream container events:
compose events. -
static async wait_exit_code(ctx: ServiceContext, configure: Callable[[DockerComposeWaitSettings], DockerComposeWaitSettings] | None=None) -> objectThe exit status the waited-on container stopped with.
compose waitexits with the container's own status, so every code is a legitimate answer and none is left to mean "compose broke". This hands the code back rather than failing the target, and still fails when compose never reached a container at all. -
static async service_port(ctx: ServiceContext, configure: Callable[[DockerComposePortSettings], DockerComposePortSettings] | None=None) -> objectThe host port a service's container port was published on. The point of letting Compose pick an ephemeral port is asking which one it picked, which is what this returns.
-
static async compose_version(ctx: ServiceContext, configure: Callable[[DockerComposeVersionSettings], DockerComposeVersionSettings] | None=None) -> objectThe installed Compose version, parsed from
compose version --format json.
class DockerComposeTopSettings(DockerComposeSettings) Settings for compose top.
-
services(*names: str) -> SelfRestrict the report to these services.
class DockerComposeUnpauseSettings(DockerComposeServiceListSettings) Settings for compose unpause.
class DockerComposeUpSettings(DockerComposeSettings) Settings for compose up.
-
detach() -> SelfRun in the background (
-d). -
build() -> SelfBuild images before starting (
--build). -
force_recreate() -> SelfRecreate containers even if unchanged (
--force-recreate). -
no_recreate() -> SelfLeave containers that already exist as they are, even when their configuration changed (
--no-recreate). Scaling a service with it only adds or removes replicas; the ones already running keep their image. -
remove_orphans() -> SelfRemove containers for services no longer defined (
--remove-orphans). -
wait() -> SelfWait until services are running/healthy (
--wait). -
abort_on_container_exit() -> SelfStop all containers if any container stops (
--abort-on-container-exit). -
no_deps() -> SelfStart only the named services, leaving their dependencies alone (
--no-deps). Without it compose starts or recreates a dependency that is stopped or whose configuration changed. With an already-healthy stack the two agree, so the difference shows up only on the runs where a dependency was not ready — which is where a target that meant "just this service" wants to be explicit. -
pull(policy: Literal['always', 'missing', 'never']) -> SelfWhen to fetch images before starting (
--pull).alwayskeeps a stack on the current published images rather than whatever was pulled last;missingfetches only what is absent locally;neveruses what is there. Distinct fromDockerComposeBuildSettings.pull, which isbuild --pull, and from thepulltask, which is the subcommand — each mirrors its own command. -
exit_code_from(service: str) -> SelfExit with this service's container's exit code (
--exit-code-from). -
scale(service: str, instances: float) -> SelfScale a service to N instances (
--scale service=N); repeatable. -
services(*names: str) -> SelfRestrict to specific services (positional); optional.
class DockerComposeVersionSettings(DockerComposeSettings) Settings for compose version.
-
format(value: str) -> SelfFormat the output (
--format),prettyorjson. -
json() -> SelfEmit JSON (
--format json). -
short() -> SelfPrint only the version number (
--short).
class DockerComposeVolumesSettings(DockerComposeListingSettings) Settings for compose volumes.
-
services(*names: str) -> SelfRestrict the listing to the volumes these services use.
class DockerComposeWaitSettings(DockerComposeSettings) Settings for compose wait.
The command blocks until the named services' containers stop, then exits with the first container's own exit status. That makes its exit code a result rather than a failure — see DockerComposeTasks.waitExitCode, which hands the code back instead of failing the target.
-
services(*names: str) -> SelfThe services to wait on (required).
-
down_project() -> SelfTear the project down once the first container stops (
--down-project), so a test run cleans up after itself without a second command.