docker_compose_logs
View and monitor Docker Compose service logs to troubleshoot issues, track container activity, and analyze application performance in development and production environments.
Instructions
Show logs from Docker Compose services
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| directory | No | Directory containing docker-compose.yml | |
| service | No | Specific service name | |
| tail | No | Number of lines (default: 100) |
Implementation Reference
- src/tools/docker/compose.ts:20-38 (handler)The actual implementation of the tool logic that executes 'docker compose logs' via child_process.
export async function composeLogs(args: Record<string, unknown>): Promise<string> { const directory = (args.directory as string) || "."; const service = args.service as string | undefined; const tail = (args.tail as number) || 100; const composeArgs = ["compose", "logs", "--no-color", `--tail=${tail}`]; if (service) composeArgs.push(service); try { const { stdout } = await execFileAsync("docker", composeArgs, { cwd: directory, timeout: 30000, }); return stdout.trim() || "No compose logs found."; } catch (error) { const msg = error instanceof Error ? error.message : String(error); throw new Error(`Failed to get compose logs: ${msg}`); } } - src/tools/docker/index.ts:84-95 (registration)Registration and definition of the 'docker_compose_logs' tool.
{ name: "docker_compose_logs", description: "Show logs from Docker Compose services", inputSchema: { type: "object" as const, properties: { directory: { type: "string", description: "Directory containing docker-compose.yml" }, service: { type: "string", description: "Specific service name" }, tail: { type: "number", description: "Number of lines (default: 100)" }, }, }, }, - src/tools/docker/index.ts:128-128 (handler)The handler switch statement routing the tool request to the implementation function 'composeLogs'.
case "docker_compose_logs": return composeLogs(a);