compose_exec
Run any command inside an existing Docker Compose service container, with control over user, working directory, and environment variables. Returns stdout, stderr, and exit code.
Instructions
Run a command inside an already-running compose service container.
Always passes -T (no TTY). Pass an exec-form argv (e.g. ["python", "-V"]); a
["sh", "-c", "..."] form interprets shell metacharacters in untrusted substrings.
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)
files - Explicit compose file paths (repeatable, -f)
project_name - Compose project name override
index - Container index when the service has multiple replicas (default 1)
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 |