Docker

How to Debug a Docker Container That Keeps Restarting

Break a Docker restart loop by inspecting container state, exit codes, logs, health checks, configuration, and resource limits.

Updated 2026-07-122 min read

A Docker container restarts because its main process exits and a restart policy starts it again. Preserve the evidence before recreating the container.

Inspect state and exit code

docker ps -a --filter name=my-container
docker inspect my-container --format '{{json .State}}'
docker inspect my-container --format '{{json .HostConfig.RestartPolicy}}'

Common exit codes include 1 for an application error, 126 or 127 for command problems, and 137 when the process may have been killed for memory pressure.

Read logs from the failed run

docker logs --tail 200 --timestamps my-container

If logging is empty, confirm that the application writes to stdout and stderr. Inspect Docker daemon events as well:

docker events --since 30m --filter container=my-container

Check memory and health status

docker inspect my-container --format '{{.State.OOMKilled}}'
docker inspect my-container --format '{{json .State.Health}}'

A health check does not normally restart a standalone container by itself, but orchestrators and external automation may act on it.

Compare configuration

Review the effective command, entrypoint, environment, mounts, and user:

docker inspect my-container --format '{{json .Config.Cmd}} {{json .Config.Entrypoint}}'
docker inspect my-container --format '{{json .Mounts}}'

Do not paste secret-bearing environment output into tickets or public logs.

Diagnose it with Rumus

AI-native terminal Commands require your approval
Why use Rumus for this diagnosis?

Rumus is an AI-native terminal that can inspect both Docker and its Linux host in one workflow. It connects container state, logs, mounts, networking, and resource limits so you can fix the cause without blindly recreating workloads.

What Rumus can inspect

  • Container state, exit codes, logs, and health checks
  • Images, mounts, ports, users, and restart policies
  • Host resources and Docker daemon context
Download Rumus
Diagnose why my-container keeps restarting. Inspect its state, exit code, restart
policy, recent logs, OOM status, health check, command, mounts, and relevant Docker
events. Redact secrets and do not recreate or stop the container without approval.

Confirm the fix

Deploy the corrected configuration and watch more than one restart interval:

docker ps --filter name=my-container
docker logs --follow --tail 50 my-container

Verify the application endpoint, not only the container’s Up status.

Diagnose the real environment

Open the server in Rumus and let the AI agent inspect context, propose a plan, and ask before it runs changes.

Download Rumus