service_create_from_image
Creates a new service on Railway using a specified Docker image, ideal for custom database setups or pre-built container deployments with specific version requirements.
Instructions
[API] Create a new service from a Docker image
⚡️ Best for: ✓ Custom database deployments ✓ Pre-built container deployments ✓ Specific version requirements
⚠️ Not for: × Standard database deployments (use database_deploy) × GitHub repository deployments (use service_create_from_repo) × Services needing build process
→ Prerequisites: project_list
→ Alternatives: database_deploy, service_create_from_repo
→ Next steps: variable_set, service_update, tcp_proxy_create
→ Related: volume_create, deployment_trigger
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image | Yes | Docker image to use (e.g., 'postgres:13-alpine') | |
| name | No | Optional custom name for the service | |
| projectId | Yes | ID of the project to create the service in |
Implementation Reference
- src/tools/service.tool.ts:89-119 (registration)Tool registration including description, input schema (Zod), and thin handler that delegates to serviceService.createServiceFromImagecreateTool( "service_create_from_image", formatToolDescription({ type: 'API', description: "Create a new service from a Docker image", bestFor: [ "Custom database deployments", "Pre-built container deployments", "Specific version requirements" ], notFor: [ "Standard database deployments (use database_deploy)", "GitHub repository deployments (use service_create_from_repo)", "Services needing build process" ], relations: { prerequisites: ["project_list"], nextSteps: ["variable_set", "service_update", "tcp_proxy_create"], alternatives: ["database_deploy", "service_create_from_repo"], related: ["volume_create", "deployment_trigger"] } }), { projectId: z.string().describe("ID of the project to create the service in"), image: z.string().describe("Docker image to use (e.g., 'postgres:13-alpine')"), name: z.string().optional().describe("Optional custom name for the service") }, async ({ projectId, image, name }) => { return serviceService.createServiceFromImage(projectId, image, name); } ),
- src/services/service.service.ts:107-124 (handler)Main handler function implementing service creation from Docker image using the Railway client API, with error handling and response formatting.async createServiceFromImage(projectId: string, image: string, name?: string) { try { const service = await this.client.services.createService({ projectId, name, source: { image, } }); return createSuccessResponse({ text: `Created new service "${service.name}" (ID: ${service.id}) from Docker image "${image}"`, data: service }); } catch (error) { return createErrorResponse(`Error creating service: ${formatError(error)}`); } }