Skip to main content
Glama

docker_compose

Manage Docker Compose services by performing actions like starting, stopping, viewing logs, checking status, restarting, and building containers.

Instructions

Manage Docker Compose services

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesDocker Compose action to perform
buildNoBuild images before starting (for up action)
detachNoRun in detached mode
serviceNoSpecific service name (optional)

Implementation Reference

  • src/index.ts:1816-1876 (registration)
    Full registration of the 'docker_compose' tool, including title, description, inputSchema, and the complete handler function that executes docker-compose commands based on the specified action.
    server.registerTool( "docker_compose", { title: "Docker Compose Management", description: "Manage Docker Compose services", inputSchema: { action: z.enum(["up", "down", "logs", "ps", "restart", "build"]).describe("Docker Compose action to perform"), service: z.string().optional().describe("Specific service name (optional)"), detach: z.boolean().optional().default(true).describe("Run in detached mode"), build: z.boolean().optional().describe("Build images before starting (for up action)") } }, async ({ action, service, detach, build }) => { try { let command: string; const serviceArg = service ? ` ${service}` : ""; switch (action) { case "up": command = `docker-compose up${detach ? " -d" : ""}${build ? " --build" : ""}${serviceArg}`; break; case "down": command = `docker-compose down${serviceArg}`; break; case "logs": command = `docker-compose logs${serviceArg}`; break; case "ps": command = "docker-compose ps"; break; case "restart": command = `docker-compose restart${serviceArg}`; break; case "build": command = `docker-compose build${serviceArg}`; break; } const result = await executeDockerCommand(command); return { content: [ { type: "text", text: `Docker Compose ${action} completed:\n\n${result.stdout}${result.stderr ? `\nWarnings:\n${result.stderr}` : ""}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error with Docker Compose: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
  • Handler function for 'docker_compose' tool. Constructs docker-compose CLI command based on action (up, down, logs, ps, restart, build), optionally for a specific service, with flags for detach and build, executes it via executeDockerCommand, and returns formatted output or error.
    async ({ action, service, detach, build }) => { try { let command: string; const serviceArg = service ? ` ${service}` : ""; switch (action) { case "up": command = `docker-compose up${detach ? " -d" : ""}${build ? " --build" : ""}${serviceArg}`; break; case "down": command = `docker-compose down${serviceArg}`; break; case "logs": command = `docker-compose logs${serviceArg}`; break; case "ps": command = "docker-compose ps"; break; case "restart": command = `docker-compose restart${serviceArg}`; break; case "build": command = `docker-compose build${serviceArg}`; break; } const result = await executeDockerCommand(command); return { content: [ { type: "text", text: `Docker Compose ${action} completed:\n\n${result.stdout}${result.stderr ? `\nWarnings:\n${result.stderr}` : ""}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error with Docker Compose: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
  • Zod input schema for 'docker_compose' tool defining required action enum and optional service, detach (default true), build parameters.
    inputSchema: { action: z.enum(["up", "down", "logs", "ps", "restart", "build"]).describe("Docker Compose action to perform"), service: z.string().optional().describe("Specific service name (optional)"), detach: z.boolean().optional().default(true).describe("Run in detached mode"), build: z.boolean().optional().describe("Build images before starting (for up action)") }
  • Helper function executeDockerCommand used by the docker_compose handler (and other tools) to promisify and execute shell docker-compose commands.
    async function executeDockerCommand(command: string): Promise<{ stdout: string; stderr: string }> { try { const result = await execAsync(command); return result; } catch (error: any) { throw new Error(`Docker command failed: ${error.message}`); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TauqeerAhmad5201/docker-mcp-extension'

If you have feedback or need assistance with the MCP directory API, please join our Discord server