Skip to main content
Glama

container_create

Create and start Docker containers with image selection, port mapping, and environment variable configuration.

Instructions

Create and start a new Docker container

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageYesDocker image name
nameNoContainer name
portsNoPort mappings (e.g. ["80:80"])
envNoEnvironment variables (e.g. ["KEY=value"])

Implementation Reference

  • Core implementation of container creation logic: builds 'docker run' command with image, name, ports, env and executes it.
    async createContainer(params: { image: string; name?: string; ports?: string[]; env?: string[]; }): Promise<string> { const { image, name, ports, env } = params; let cmd = 'run -d'; if (name) cmd += ` --name ${name}`; if (ports) { ports.forEach(p => cmd += ` -p ${p}`); } if (env) { env.forEach(e => cmd += ` -e ${e}`); } cmd += ` ${image}`; return this.executeCommand(cmd); }
  • MCP CallToolRequestSchema handler for 'container_create': parses arguments and delegates to dockerService.createContainer.
    case 'container_create': { const { image, name, ports, env } = request.params.arguments as { image: string; name?: string; ports?: string[]; env?: string[]; }; const output = await this.dockerService.createContainer({ image, name, ports, env, }); return { content: [{ type: 'text', text: `Container created: ${output}` }], }; }
  • Tool registration in ListToolsRequestSchema response: defines name, description, and input schema for container_create.
    { name: 'container_create', description: 'Create and start a new Docker container', inputSchema: { type: 'object', properties: { image: { type: 'string', description: 'Docker image name', }, name: { type: 'string', description: 'Container name', }, ports: { type: 'array', items: { type: 'string' }, description: 'Port mappings (e.g. ["80:80"])', }, env: { type: 'array', items: { type: 'string' }, description: 'Environment variables (e.g. ["KEY=value"])', }, }, required: ['image'], }, },
  • Input schema definition for container_create tool, specifying properties and requirements.
    inputSchema: { type: 'object', properties: { image: { type: 'string', description: 'Docker image name', }, name: { type: 'string', description: 'Container name', }, ports: { type: 'array', items: { type: 'string' }, description: 'Port mappings (e.g. ["80:80"])', }, env: { type: 'array', items: { type: 'string' }, description: 'Environment variables (e.g. ["KEY=value"])', }, }, required: ['image'], },

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/Toowiredd/chatgpt-mcp-server'

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