swarm_task_logs
Retrieve a bounded snapshot of logs from a specific Docker Swarm task to diagnose failures without following the stream, even on multi-node clusters.
Instructions
Get a bounded snapshot of one swarm task's logs (never follows).
The per-replica counterpart to service_logs, which interleaves every task in the service: use
this to read the replica that actually failed, found with swarm_task_list or service_ps.
container_logs is no substitute on a multi-node swarm - the task's container lives on
whichever node the scheduler placed it on, and this server talks to one daemon.
As with service_logs, follow is not exposed (the stream is joined into one string before
returning, so following would never finish) and collection is capped at max_bytes. The Engine
offers no until bound here, unlike container_logs, so narrow with since or an integer
tail.
docker-py has no task collection and no APIClient.task_logs, so this drives its private
request helpers against the published GET /tasks/{id}/logs, raising CapabilityError if those
internals move. Drop the reach-in if docker-py grows a public method.
Args:
id_or_name: The task id, an unambiguous id prefix, or its full <service>.<slot>.<taskid> name; see
swarm_task_inspect for how the daemon resolves these and which name forms do not work
since: Show logs since this Unix timestamp
tail: Number of lines from the end, or the literal "all" for everything
max_bytes: Abort with ToolInputError if the buffered logs exceed this many bytes (default 32 MiB)
Returns: str: Decoded log output
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tail | No | ||
| since | No | ||
| stderr | No | ||
| stdout | No | ||
| details | No | ||
| max_bytes | No | ||
| id_or_name | Yes | ||
| timestamps | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |