Skip to content
DevOps AI ToolKit
Newsletter
All prompts
Docker with AI Difficulty: Intermediate ClaudeChatGPT

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.

Related prompts

Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 2,104 DevOps AI prompts
  • One practical workflow email per week