This prompt is designed for the moment after a docker compose up command fails with a non-zero exit code. It is a targeted recovery tool for platform engineers and developers who have already written a docker-compose.yml file and are staring at container logs or error output they cannot immediately resolve. The job-to-be-done is not initial file generation or architectural design; it is rapid, context-aware debugging of a runtime failure. The ideal user has the failing Compose file, the full terminal error output, and a need for a corrected service definition, environment block, or dependency map that can be applied directly to unblock their workflow.
Prompt
Docker Compose Service Startup Failure Recovery Prompt

When to Use This Prompt
Identify the exact scenarios where this Docker Compose recovery prompt is the right tool, and when a different approach is required.
Use this prompt when the failure is not a simple YAML syntax error—docker compose config can handle basic linting—but a logical or environmental mismatch. This includes port conflicts between services or with the host, invalid volume mount paths or permissions, environment variables that are missing, misspelled, or of the wrong type, and inter-service dependency chains where a critical backend is not yet healthy when a dependent service starts. The prompt instructs the model to act as a senior DevOps engineer, reasoning across the entire Compose file and error context to isolate the root cause. It is particularly effective when the error message is verbose or multi-layered, such as a Java stack trace from a container that crashed because a database URL was misconfigured.
Do not use this prompt for greenfield Compose file generation, architectural reviews, or multi-service orchestration design. It is not a substitute for a docker compose config syntax check, and it will not be effective if you provide only a generic error like 'container exited with code 1' without the associated logs. For failures involving external infrastructure—such as a cloud provider's managed database being unreachable due to a network ACL—this prompt can identify the symptom but will not have the context to fix the external resource. In those cases, pair the output with a cloud-specific recovery prompt. After receiving the corrected YAML snippet, always validate it with docker compose config and a dry-run docker compose up --no-start before applying it to a shared environment.
Use Case Fit
Where the Docker Compose Service Startup Failure Recovery Prompt works, where it does not, and the operational risks to manage before wiring it into a production harness.
Good Fit: Deterministic Config Errors
Use when: The failure is a deterministic configuration error (port conflicts, invalid volume mounts, missing environment variables, syntax errors) where the compose file and container logs contain enough signal to diagnose the root cause. Guardrail: The harness must provide the full compose file and the exact error output; partial logs lead to hallucinated fixes.
Bad Fit: Transient Infrastructure Failures
Avoid when: The failure is caused by external infrastructure issues (network timeouts, registry unavailability, disk pressure, kernel bugs) that are not visible in the compose file or container logs. Guardrail: Classify the error type before invoking the prompt; route infrastructure failures to an operational runbook, not a config repair prompt.
Required Inputs: Compose File and Error Logs
What to watch: The prompt cannot diagnose failures without both the original compose file and the full startup error output. Missing either input produces plausible but incorrect suggestions. Guardrail: Validate that both inputs are present and non-empty before sending the prompt; return a structured error to the caller if inputs are incomplete.
Operational Risk: Unsafe Volume Mount Suggestions
What to watch: The model may suggest volume mounts that expose sensitive host paths or weaken container isolation to resolve permission errors. Guardrail: Post-process all suggested volume mount paths against a deny list of sensitive directories (/etc, /var/run, $HOME/.ssh); require human review for any mount that crosses the deny-list boundary.
Operational Risk: Port Conflict Resolution
What to watch: The model may suggest changing host ports without checking for conflicts with other running services, creating new failures downstream. Guardrail: Validate all suggested port assignments against the host's current port usage before applying; reject suggestions that collide with known allocations.
Operational Risk: Dependency Ordering Changes
What to watch: The model may reorder depends_on or service startup sequences in ways that break application initialization logic. Guardrail: Diff the suggested compose file against the original and flag any dependency-order changes for human review; never auto-apply ordering changes without confirmation.
Copy-Ready Prompt Template
A reusable prompt template with square-bracket placeholders for diagnosing and recovering from Docker Compose service startup failures.
This prompt is designed to be pasted directly into your AI harness, LLM playground, or automated recovery pipeline. It accepts a failing Docker Compose file, the associated container logs, and any relevant environment context, then instructs the model to diagnose the root cause and produce a corrected service definition. The output is structured to be machine-readable, allowing your harness to parse the suggested fix and optionally apply it in a controlled retry loop.
textYou are an expert DevOps engineer specializing in Docker and container orchestration. Your task is to diagnose a Docker Compose service startup failure and provide a corrected configuration. ## INPUT - Failing Docker Compose file: ```yaml [DOCKER_COMPOSE_YAML]
- Container logs or error output:
text[CONTAINER_LOGS]
- Additional context (optional): [ADDITIONAL_CONTEXT]
CONSTRAINTS
- Preserve the original service names and overall architecture unless they are the direct cause of the failure.
- Do not change the base image unless the specified tag is invalid or incompatible.
- If suggesting new environment variables, explain why they are needed.
- If modifying
depends_on, ensure the dependency graph remains acyclic and logical. - For port conflicts, suggest an alternative host port or identify the conflicting process.
- For volume mount errors, verify the host path exists and the container has correct permissions.
OUTPUT_SCHEMA
Respond with a valid JSON object containing the following fields: { "root_cause": "A concise, one-sentence summary of the primary failure cause.", "diagnosis": "A detailed explanation of the error, referencing specific lines from the logs and compose file.", "corrected_compose": "The full, corrected Docker Compose YAML content as a single string.", "changes_summary": ["A list of specific changes made, e.g., 'Changed port mapping from 80:80 to 8080:80'."], "requires_manual_intervention": true_or_false, "manual_steps": "If manual intervention is required, list the steps. Otherwise, set to null." }
RISK_LEVEL
This is a [RISK_LEVEL] operation. If [RISK_LEVEL] is 'high', flag any destructive changes (like volume re-creation) in requires_manual_intervention.
To adapt this template, replace the square-bracket placeholders with your actual data. [DOCKER_COMPOSE_YAML] should contain the raw text of your docker-compose.yml file. [CONTAINER_LOGS] should include the output from docker compose logs or the specific error message from the failing service. Use [ADDITIONAL_CONTEXT] to pass in details like the host OS, Docker version, or recent changes. Set [RISK_LEVEL] to 'low', 'medium', or 'high' to control the model's caution. The harness should parse the JSON output and, if requires_manual_intervention is false, can proceed to write the corrected_compose to a file and run docker compose up -d as a retry step. Always validate the corrected YAML with a linter before applying it to avoid introducing syntax errors.
Prompt Variables
Required inputs for the Docker Compose Service Startup Failure Recovery Prompt. Each placeholder must be populated before the prompt is sent. Validation notes describe how the harness should check input quality before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[COMPOSE_FILE] | The full docker-compose.yml content that failed to start | services: app: image: node:18 ports: - "3000:3000" | Parse check: must be valid YAML. Schema check: must contain at least one service definition. Null not allowed. |
[CONTAINER_LOGS] | Raw stdout/stderr logs from the failing container or docker compose up output | app-1 | Error: Cannot find module '/app/server.js' app-1 exited with code 1 | Parse check: must be non-empty string. Null not allowed. Length check: truncate at 8000 tokens to avoid context overflow. |
[EXIT_CODE] | The numeric exit code from the failed container or compose process | 1 | Type check: must be integer. Range check: 0-255. Null allowed if exit code is unavailable. |
[SERVICE_NAME] | The name of the failing service as defined in the compose file | app | Schema check: must match a service key in [COMPOSE_FILE]. Null not allowed. |
[HOST_ENVIRONMENT] | Operating system and Docker runtime details for context-aware suggestions | macOS 14.2, Docker Desktop 4.27, Compose v2.23 | Parse check: must be non-empty string. Contains OS, Docker version, Compose version. Null allowed; prompt degrades to generic suggestions. |
[RETRY_COUNT] | Number of previous recovery attempts for this failure | 2 | Type check: must be non-negative integer. Used by harness to decide escalation threshold. Null defaults to 0. |
[ESCALATION_THRESHOLD] | Maximum retry attempts before human handoff | 3 | Type check: must be positive integer. Harness compares against [RETRY_COUNT] to stop retry loop. Null defaults to 3. |
Implementation Harness Notes
How to wire the Docker Compose startup failure recovery prompt into a reliable application or CI workflow.
This prompt is designed to be called programmatically after a docker compose up command exits with a non-zero code or when container health checks fail. The harness should capture the full compose file content, the complete stdout/stderr log output from the failed run, and any relevant environment variable files before constructing the prompt payload. Do not truncate logs prematurely—the model needs the full error context to diagnose issues like port conflicts, volume mount permission errors, or dependency service startup ordering problems. The harness must also inject the [OUTPUT_SCHEMA] placeholder with a strict JSON schema that defines the expected structure: a diagnosis string, a corrected_compose string containing the full corrected YAML, a changes array of objects describing each modification with field, before, after, and reason keys, and a requires_manual_review boolean flag for cases where the fix involves external resources like network creation or filesystem permissions.
Before executing the prompt, validate that the input compose file is syntactically valid YAML. If the file fails to parse, do not call the model—return a harness-level error indicating the YAML is malformed. After receiving the model response, the harness must perform several validation steps before applying any changes. First, parse the corrected_compose field as YAML and verify it is structurally valid. Second, diff the original and corrected compose files to confirm that the changes array accurately reflects every modification. Third, run a port conflict check: extract all host-port mappings from the corrected compose and verify no two services bind to the same host port. Fourth, validate volume mount paths exist on the host filesystem or are defined as named volumes within the compose file. If any validation step fails, log the failure, increment a retry counter, and re-invoke the prompt with the validation error message appended to the [INPUT] context. Set a maximum of three retry attempts before escalating to a human operator.
For production deployments, integrate this prompt into your CI pipeline as a pre-apply safety check rather than an automatic fixer. When the prompt produces a corrected_compose with requires_manual_review set to true, the harness must block the pipeline and post the proposed changes to a review queue—never auto-apply fixes that involve network configuration, security-sensitive volume mounts, or privilege escalations. Log every prompt invocation, including the original error, the model's diagnosis, the proposed changes, validation results, and the final disposition (applied, rejected, or escalated). Use structured logging with trace IDs that link the compose file hash, the error signature, and the prompt response for post-incident analysis. Choose a model with strong YAML generation and instruction-following capabilities; smaller models often introduce subtle YAML indentation errors or omit required service keys, so prefer models with proven structured output reliability for this workflow.
Expected Output Contract
The model must return a structured recovery plan. Use this contract to validate the response before applying any suggested changes to a Docker Compose file.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
recovery_plan | object | Top-level key must exist and be a JSON object. | |
recovery_plan.diagnosis | string | Must be a non-empty string summarizing the root cause identified from [ERROR_LOG] and [COMPOSE_FILE]. | |
recovery_plan.corrected_compose_snippet | string | Must be a valid YAML string block containing only the changed or added service definitions. Parse check: YAML must load without errors. | |
recovery_plan.changes | array of objects | Each object must have 'field' (string), 'before' (string or null), 'after' (string), and 'reason' (string). Array must not be empty. | |
recovery_plan.port_conflict_check | object | Must contain 'host_ports' (array of strings) and 'container_ports' (array of strings). Validate no duplicate host ports exist across services in the corrected snippet. | |
recovery_plan.volume_mount_validation | array of strings | List of host paths referenced in the corrected snippet. Each path must be an absolute path or a named volume. Relative paths are invalid. | |
recovery_plan.dependency_order | array of strings | If present, must list service names in correct startup order. Validate each name exists in the corrected snippet's service keys. | |
recovery_plan.requires_human_approval | boolean | Must be true if the fix involves changing network mode, privileged mode, or bind-mounting system directories. Otherwise false. |
Common Failure Modes
What breaks first when using AI to recover from Docker Compose startup failures, and how to guard against it in production.
Port Conflict Misdiagnosis
What to watch: The model suggests changing the container's internal port instead of the host port mapping, or fails to check for conflicts with other running services outside the Compose file. Guardrail: Always include docker ps and netstat -tulpn output in the [CONTEXT] so the model can see actual port usage, not just the Compose file.
Volume Mount Permission Drift
What to watch: The model proposes a corrected volume mount path but ignores the :Z or :z SELinux label, or suggests a UID/GID that doesn't exist on the host. Guardrail: Include ls -la output for host mount paths and id output for the container user in the [CONTEXT] block, and validate any proposed mount string against the host filesystem before applying.
Environment Variable Substitution Failure
What to watch: The model generates a corrected environment: block with unset variables or shell-style $VAR references that Docker Compose won't expand. Guardrail: Post-process the model output to detect unresolved ${} tokens and require explicit values or .env file entries before the retry harness applies the change.
Dependency Ordering Blind Spot
What to watch: The model adds depends_on with condition: service_healthy but the dependent service has no healthcheck defined, creating a startup deadlock. Guardrail: Validate that every service referenced in a depends_on condition block has a corresponding healthcheck stanza in the corrected output before applying.
Image Tag and Registry Mismatch
What to watch: The model hallucinates a newer image tag or a public registry path that doesn't exist, or suggests latest which breaks reproducibility. Guardrail: Pin the model's allowed image sources by including a [ALLOWED_REGISTRIES] constraint in the prompt, and validate any proposed image reference with docker manifest inspect before the retry harness commits.
Multi-File Override Confusion
What to watch: The model corrects the base docker-compose.yml but ignores overrides in docker-compose.override.yml or docker-compose.prod.yml, reintroducing the error on the next merge. Guardrail: Require all active Compose files to be passed in [CONTEXT] and instruct the model to output a unified diff or a corrected override file, not just the base file.
Evaluation Rubric
Use this rubric to test the Docker Compose Service Startup Failure Recovery Prompt before deploying it into a production harness. Each criterion targets a specific failure mode common in configuration recovery workflows.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Port Conflict Resolution | Output suggests a new host port or removes the conflicting service binding when [COMPOSE_FILE] and [CONTAINER_LOGS] show an address-in-use error | Output keeps the same port, suggests a random port without checking the host, or ignores the error entirely | Inject a compose file with a known port conflict and verify the corrected port is not in use by another service definition |
Volume Mount Validity | Output corrects the source path to an absolute path or removes the bind mount when [CONTAINER_LOGS] show a file-not-found or permission-denied error on a volume | Output keeps a relative path, suggests a path that does not exist on the host, or adds a volume without addressing the permission error | Provide a compose file with a broken relative bind mount and check that the corrected path is absolute and syntactically valid |
Dependency Order Correction | Output adds or reorders | Output removes the dependency, suggests a sleep timer, or ignores the startup race condition | Supply a compose file where a web service starts before its database and verify the corrected output includes a health-check-aware dependency |
Environment Variable Repair | Output adds the missing required variable or corrects the malformed value when [CONTAINER_LOGS] show an undefined-variable or invalid-config error | Output removes the variable reference, hardcodes a secret, or adds a placeholder that would fail at runtime | Provide a compose file with a missing |
Syntax and Schema Compliance | Output is valid YAML that passes | Output contains YAML syntax errors, uses unsupported Compose spec fields, or breaks indentation | Run the corrected output through |
Minimal Change Principle | Output changes only the lines directly related to the error and preserves all other service definitions, networks, and volumes intact | Output rewrites the entire file, removes unrelated services, or changes the Compose file version unnecessarily | Diff the original [COMPOSE_FILE] against the corrected output and verify that only error-related blocks are modified |
Explanation Traceability | Output includes a brief explanation that references the specific log line or error message that justified each change | Output provides no explanation, a generic statement with no log reference, or a hallucinated error that does not appear in [CONTAINER_LOGS] | Check that each correction block in the output cites a line number or error string from the provided logs |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a single compose file and raw container logs. Accept free-text output without strict schema enforcement. Focus on getting a useful suggestion, not a validated fix.
Prompt modification
- Remove [OUTPUT_SCHEMA] and [CONSTRAINTS] sections
- Replace with: "Suggest the most likely fix in plain language"
- Keep [COMPOSE_FILE] and [CONTAINER_LOGS] as the only inputs
Watch for
- Suggestions that break other services
- Overly broad changes like removing all health checks
- No indication of which service is the root cause

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us