stack_deploy
Deploy or update a Docker Swarm stack from Compose files. Supports pruning removed services, registry authentication, and optional wait for convergence.
Instructions
Deploy (or update) a stack to the swarm from one or more Compose files.
Requires the target daemon to be a swarm manager. Re-running with the same name updates the
stack in place. Defaults to detach=True (returns once specs are submitted, not on
convergence); set detach=False to wait for the rollout (give it a generous
timeout_seconds). The swarm analogue of compose_up; watch the rollout with
stack_services / stack_ps.
Does not raise on a non-zero CLI exit (a missing docker binary or a timeout still raises) - inspect
returncode/stderr in the result.
Args:
name: Name of the stack to create or update
compose_files: One or more Compose file paths (repeated -c; later override earlier). At least one required.
with_registry_auth: Send registry credentials to swarm agents (needed for private images)
prune: Remove services no longer defined in the Compose file
resolve_image: Image-digest resolution; omit for the CLI default ("always")
detach: Return immediately after submitting specs (True) vs wait for convergence (False)
cwd: Working directory for resolving relative Compose paths (defaults to the server's cwd; copied to the target
host if no local docker CLI)
timeout_seconds: Subprocess timeout (default 1800s)
Returns: dict: {"returncode": int, "stdout": str, "stderr": str, "truncated": bool}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | ||
| name | Yes | ||
| prune | No | ||
| detach | No | ||
| compose_files | Yes | ||
| resolve_image | No | ||
| timeout_seconds | No | ||
| with_registry_auth | No |