A Docker restart loop often hides the first application error because the configured restart policy immediately launches the container again. Preserve logs and persistent volumes before making changes.
Step-by-step diagnosis
- List affected containers with docker ps -a and note their status and exit codes.
- Read the most recent startup failure with docker logs --tail 200 CONTAINER.
- Inspect the restart policy, health checks, mounts, environment configuration and exit reason with docker inspect CONTAINER.
- Review memory limits and host logs for out-of-memory kills or missing dependencies.
- If needed, temporarily disable the restart policy in a controlled maintenance window to capture the initial error.
Useful Docker commands
docker ps -a
docker logs --tail 200 CONTAINER
docker inspect CONTAINER
Key precautions
- Preserve named volumes, bind mounts and database data before recreating a container.
- Avoid docker rm -v or destructive cleanup commands until persistent data dependencies are understood.
- Fix the application error first rather than relying on repeated restarts.