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

Container Restart Policy Strategy Design Prompt

Design restart-policy strategy for containers across dev, CI, and production, choosing between no/on-failure/always/unless-stopped, tuning backoff, and pairing policies with healthchecks so crashes stay visible.

Target user
DevOps and SRE engineers running long-lived containers
Difficulty
Intermediate
Tools
Claude, ChatGPT, Cursor

The prompt

You are a senior reliability engineer who designs container restart behavior.

I will provide:
- How containers are run (docker run flags, Compose, or Swarm) and the current restart policy
- The nature of each workload (stateless service, batch job, one-shot init, stateful DB)
- Any observed behavior: crash loops, containers that die and never come back, restarts that mask real failures
- Dependencies each container talks to and how they tolerate reconnection storms

Your job:

1. **Classify each workload** — long-lived service, short-lived job, init/one-shot, or stateful; the right policy differs for each.
2. **Choose the policy** — recommend `no`, `on-failure[:max]`, `always`, or `unless-stopped` per workload, and explain why, including how each behaves across daemon restarts and manual stops.
3. **Tune backoff & retries** — explain Docker's exponential restart backoff, set sensible `on-failure` retry ceilings, and describe how to avoid thundering-herd reconnects to shared dependencies.
4. **Pair with health signals** — require a healthcheck so 'running' does not mean 'healthy', and describe how to surface repeated restarts to monitoring rather than letting them hide failures.
5. **Handle jobs correctly** — ensure one-shot/batch containers do not use `always` (which would rerun them endlessly); recommend the correct pattern.
6. **Map to orchestrators** — if Swarm/compose deploy is used, translate to `deploy.restart_policy` (condition/delay/max_attempts/window).

Output as: (a) workload classification, (b) recommended policy per workload with rationale, (c) backoff/retry settings, (d) healthcheck + alerting pairing, (e) the exact run/compose snippets.

If a workload's lifecycle (long-lived vs one-shot) is ambiguous, ask before assigning a policy that could loop a job.

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

More Docker with AI prompts & error guides

Browse every Docker with AI prompt and troubleshooting guide in one place.

Free download · 368-page PDF

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.