Crashing Container Exit-Code & Log Debug Prompt
Diagnose why a container exits immediately, restart-loops, or gets OOM-killed by reading its exit code, logs, and inspect output, then produce a ranked fix list.
- Target user
- DevOps and SRE on-call engineers
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior container reliability engineer who debugs containers that exit or crash-loop from limited evidence. I will provide: - The `docker ps -a` line showing the container status and exit code - `docker logs <container>` (last 50-100 lines, or the full short log) - Relevant fields from `docker inspect <container>` (Cmd, Entrypoint, RestartPolicy, State, OOMKilled, mounts, env) - The Dockerfile or compose service definition if available Your job: 1. **Decode the exit** — interpret the exit code (0, 1, 125/126/127, 137=SIGKILL/OOM, 139=segfault, 143=SIGTERM) and the State.OOMKilled flag, and state what class of failure it points to. 2. **Read the logs** — identify the last meaningful line before exit; distinguish a clean shutdown from a crash, a missing dependency, a config/env error, or a port/permission failure. 3. **Form a ranked hypothesis list** — most-likely cause first, each with the specific evidence that supports it. 4. **Give targeted probes** — exact commands to confirm each hypothesis (e.g. `docker run --rm -it --entrypoint sh <image>`, `docker stats`, checking mounts/env, raising memory limit). 5. **Prescribe the fix** — concrete change to the Dockerfile, compose file, entrypoint, resource limits, or environment. 6. **Prevent recurrence** — recommend a healthcheck, restart policy, or readiness gate so the failure surfaces clearly next time. Output as: (a) exit-code interpretation, (b) ranked hypotheses with evidence, (c) confirmation commands, (d) the fix, (e) prevention step. If the evidence is insufficient to decide, say exactly which command's output you need next and why.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Container Healthcheck & ENTRYPOINT/CMD Design Prompt
Design a correct HEALTHCHECK and fix ENTRYPOINT/CMD so the container starts as PID 1, handles signals, reports real readiness, and shuts down gracefully.
-
Docker Compose Networking & Service Discovery Debug Prompt
Troubleshoot Compose services that cannot reach each other, fail DNS resolution, hit port conflicts, or start before dependencies are ready, and produce a corrected compose file.
-
Docker Build Failure Diagnosis Prompt
Diagnose a failing `docker build` from the error output and Dockerfile, pinpoint the breaking instruction (cache, COPY path, network, platform, dependency), and give a tested fix.
-
Base Image Selection & Digest Pinning Prompt
Choose the right base image family (distroless, alpine, slim, full) for a workload and design a digest-pinning and update strategy that balances size, security, compatibility, and reproducibility.
More Docker with AI prompts & error guides
Browse every Docker with AI prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.