SOURCE VERIFIEDSource review Sep 6, 2026No hands-on test claimed3 sources

Docker container keeps restarting in a loop

A Docker container that repeatedly returns to a running/restarting state can be caused by its main process exiting while a restart policy relaunches it. First inspect the container state, restart count and policy; also note that Docker only activates a restart policy after the container has started successfully for at least 10 seconds.

SymptomA Docker container repeatedly enters running/restarting states because its main process exits and a restart policy relaunches it.
Problem familyServers · Docker
Highest step riskCaution
Editorial statePublic launch · indexed
Affected scope
Docker EngineLinux containersRestart policiesdocker run
Start here

Inspect restart count, state and policy

Inspect the container’s restart count, state and configured restart policy first. If the main process is exiting with an error while the policy is always or unless-stopped, fix the process/configuration causing the exit; changing the restart policy only hides the loop.

  1. Run docker inspect for the affected container.
  2. Check .RestartCount and the container State information.
  3. Check the configured restart policy under HostConfig.RestartPolicy.
  4. Use the exit state and policy together to determine whether the application is crashing and being relaunched.

Why this branch first: Docker documents restart policies and exposes restart count and detailed container state through docker inspect.

TroubleByte diagnostic diagram showing a container start, process exit and restart-policy loop.
Docker restart-loop pathTroubleByte · Original TroubleByte editorial diagram
Visual diagnosis

TroubleByte diagnostic path

01
State

Inspect container state, exit details and restart count.

02
Timing

Check whether it stayed up long enough for the restart policy to apply.

03
Root cause

Read application logs and find why the main process exits.

04
Policy

Only adjust restart policy deliberately for diagnosis.

Original TroubleByte diagnostic map. It summarizes the cited troubleshooting order; it is not a vendor screenshot.

Decision checks

Use the symptom to choose the next branch

Do the container logs or inspect output show the application process exiting?

YES

Fix the application/configuration exit cause first; the restart policy is only repeating the failure.

NO

Inspect restart policy, health checks, daemon events and external orchestration before changing application code.

Does the container remain running for roughly 10 seconds before the restart policy engages?

YES

The restart policy can legitimately restart it after later exits; use logs and exit code to find the root cause.

NO

Do not assume the restart policy is the only cause; verify immediate startup failure and Docker restart-policy behavior.

Original TroubleByte decision aid derived from the cited troubleshooting scope. It does not replace vendor documentation.

Diagnosis

What this usually means

Docker restart policies control what the daemon does after a container exits, but Docker documents an important guardrail: the policy only takes effect after the container has started successfully, defined as staying up for at least 10 seconds. For containers that pass that threshold, policies such as always or unless-stopped can make an application failure look like a Docker failure because the main process exits and the container is relaunched.

What the evidence establishes

What we verified from the source material

Docker documents that restart policies decide whether a container is relaunched after its main process exits, with an important qualification: the policy only becomes active after the container has stayed up for at least 10 seconds. Policies such as always and unless-stopped can therefore expose later application crashes as visible restart loops. Docker’s CLI documentation also exposes container state and restart-policy data; the policy itself does not repair the process that is exiting.

Before you change anything

Prerequisites and checks

Prepare first

  • Know the container name or ID.
  • Capture current logs and inspect state before recreating or deleting the container.
  • Do not disable a restart policy permanently until you understand why the main process is exiting.

Checks that prevent the wrong fix

  • Record the container name or ID before changing anything.
  • Check how long the container remains up; Docker documents a 10-second successful-start threshold before restart policy activation.
  • Inspect the exit state and application logs before disabling restart behavior.
  • Changing a restart policy can alter service availability; do it deliberately.
Scope

Applies to

✓ Docker Engine✓ Linux containers✓ Restart policies✓ docker run
Troubleshooting path

Solutions, in order

01
SAFE · START HERE

Inspect restart count, state and policy

  1. Run docker inspect for the affected container.
  2. Check .RestartCount and the container State information.
  3. Check the configured restart policy under HostConfig.RestartPolicy.
  4. Use the exit state and policy together to determine whether the application is crashing and being relaunched.

Why this can work: Docker documents restart policies and exposes restart count and detailed container state through docker inspect.

02
SAFE

Fix the process that exits before changing restart policy

  1. Review the container application logs and recent configuration changes.
  2. Identify why the container’s main process exits.
  3. Correct the application, command, environment or dependency causing the exit.
  4. Start the container and verify that it stays running before treating the loop as resolved.

Why this can work: A restart policy reacts to container exit; it does not repair the process that caused the exit. Fixing the failing process preserves the intended availability policy.

03
CAUTION

Temporarily adjust restart policy for diagnosis

  1. If repeated restarts prevent diagnosis, note the current policy first.
  2. Use docker update --restart with an appropriate temporary policy for the container.
  3. Diagnose and fix the exit cause.
  4. Restore the intended production restart policy afterward.

Why this can work: Docker supports changing the restart policy of an existing container, but the policy should match the intended service behavior.

Verification

How to know the fix actually worked

  1. Confirm the container remains running beyond the previous failure interval.
  2. Recheck the restart count and verify it is no longer increasing.
  3. Inspect fresh logs to confirm the original exit condition is gone rather than merely hidden by a policy change.

Do not count a temporary disappearance of the symptom as a confirmed fix if the problem normally returns after a restart, reconnect or several minutes of use.

Stop conditions

When not to keep changing things

  • If the process exits because of missing secrets, corrupted data, storage failure or an application-level fatal error, fix that dependency before changing restart policy.
  • If the container hosts production data, stop before destructive recreate/prune operations unless you have a verified backup and understand mounted volumes.

Escalation: If the process exits without a useful application log, inspect the container state, entrypoint/command, mounts, environment variables and resource limits. The restart loop is a symptom; the exit reason is the root problem.

Evidence

Sources used for this record

Primary · checked Sep 6, 2026Docker — Start containers automaticallyOfficial documentation used to verify the troubleshooting steps.Corroborating · checked Sep 6, 2026Docker — docker container run — restart policies and restart countOfficial CLI reference for restart policies and restart-count inspection.Corroborating · checked Sep 6, 2026Docker — docker inspectOfficial reference for inspecting low-level container state.
Who reviewed this

Mihailo Ivanjac

This record was written and source-reviewed by Mihailo Ivanjac. Source review means the cited documentation was checked against the troubleshooting order on this page; it does not imply a hands-on reproduction unless the page explicitly says so.

Author profile and editorial scope →
Community troubleshooting

Discuss this exact problem

Share what happened on your system, ask a focused follow-up question, or add evidence that may help someone with the same symptom. Community posts are separate from TroubleByte editorial verification.

Before posting Do not include passwords, API keys, recovery codes, private IP addresses or other secrets. TroubleByte automatically attaches only coarse OS, browser and device-class context. Your full Browser & System Info report is not uploaded automatically.
Start a discussion

Loading community discussions…
Keep diagnosing

Related Servers problems

Change log

Revision history

Show 7 recorded revisions

2026-09-06 — v0.6 media/performance pass: added a dedicated social preview card and an original diagnostic diagram; indexing remains disabled.

2026-09-06 — v0.5 UX/discovery pass: added decision-oriented diagnostic guidance and kept indexing disabled.

2026-09-06 — v0.4 depth pass: added symptom framing, prerequisites, verification checks and explicit stop conditions; indexing remains disabled.

2026-09-06 — v0.3 trust pass: assigned a named human author/source reviewer, added section taxonomy and an original diagnostic flow; indexing remains disabled.

2026-09-06 — Added Docker’s documented 10-second successful-start threshold so restart-loop guidance does not overgeneralize very early startup failures.

2026-09-06 — Clarified source-review semantics and evidence scope; no hands-on hardware test is claimed.

2026-09-06 — Created from current Docker restart-policy and inspect documentation; held noindex for review.