compose_exec
Run commands inside a running Docker Compose service container. Specify service and argv, with options for user, workdir, env, and project files.
Instructions
Run a command inside an already-running compose service container (see also container_exec).
Always passes -T (no TTY). Pass an exec-form argv (e.g. ["python", "-V"]); a
["sh", "-c", "..."] form interprets shell metacharacters in untrusted substrings.
Does not raise on a non-zero CLI exit (a missing compose plugin or a timeout still raises) - inspect
returncode/stderr in the result.
Args:
service: Service name from the compose file
command: Argv to execute inside the container
project_dir: Dir with the compose file (default: server cwd; copied to the target host if no local plugin)
files: Explicit compose file paths (repeatable, -f)
project_name: Compose project name override
index: Container index when the service has multiple replicas
workdir: Working directory inside the container
user: User to run as inside the container (uid or name)
env: Environment variables to set for the exec session
timeout_seconds: Subprocess timeout (default 60s)
Returns: dict: {"returncode": int, "stdout": str, "stderr": str, "truncated": bool}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| env | No | ||
| user | No | ||
| files | No | ||
| index | No | ||
| command | Yes | ||
| service | Yes | ||
| workdir | No | ||
| project_dir | No | ||
| project_name | No | ||
| timeout_seconds | No |