Help for owners
My app keeps restarting on the server
Short answer
A container that restarts again and again is crashing on start, and a restart policy is bringing it back each time. The policy hides the crash but does not fix it. Do not delete containers or volumes. Ask your engineer for the container logs, which usually say why.
Does this sound like your situation?
- My site goes up and down every few minutes.
- The server is slow and the status shows restarting.
- It worked until a setting was changed or an update was run.
- The disk is nearly full.
- Only one part, such as the database or the API, keeps dropping.
Why does this happen?
A restart policy keeps bringing a failing app back
Docker documents restart policies that start a container again after it stops, for example when it exits with an error. It says a policy takes effect only after the container has started successfully. So a loop is a sign the app itself is failing, over and over.
Confirmed by docs.docker.com
Wrong or missing settings
A changed password, an environment value or a missing file makes the app exit at start.
Technical detail: A Docker container keeps restarting and never stays up
The machine ran out of space or memory
A full disk or full memory stops databases and apps, and the policy restarts them into the same wall.
Technical detail: The Postgres container cannot write postmaster.pid because Docker is out of disk
A dependency is not ready
An app that starts before its database is available exits, then repeats.
What can I do about it today?
- Do not delete containers, images or volumesVolumes hold your data. Deleting them to start fresh can destroy it.
- Do not keep rebooting the serverIt does not fix the cause and can corrupt data if a database is writing.
- Ask for the container logsAsk your developer or host to send the last lines from the failing container. They usually name the reason.
- Check disk spaceAsk whether the disk is nearly full. It is a common and quick-to-confirm cause.
- Tell your engineer what changed lastAn update, a new setting, a server move. The last change is often the cause.
When should I bring someone in?
- The loop affects a database or anything that holds customer data.
- Your site is down for customers.
- Nobody can read the logs.
How do I handle it?
- Back up before touching anythingVolumes and the database are copied out first.
- Read the logs and the exit reasonI find why the container stops and what changed before it began.
- Fix the cause, not the policySettings, space, memory or start order are corrected, then the container is allowed to run on its own.
- Add a warningAn alert tells you when a container restarts, instead of a customer telling you.
The price depends on what I find, so I quote in writing after a short discovery call. Tell me what is happening and I reply within 24 hours.
What do owners ask about this?
Should I turn the restart policy off?
Not as a first step. It keeps the app up when something brief fails, and Docker says it applies after a successful start.
Is my data lost?
Usually not, unless volumes were deleted. That is why I ask you not to remove them.
Can this happen again?
Yes if the cause is not removed, so I add checks and an alert.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Found a mistake? Tell me.
For your developer: the technical fixes
docker ps shows an uptime of a few seconds that never growsA Docker container keeps restarting and never stays upFATAL: could not write lock file "postmaster.pid": No space left on deviceThe Postgres container cannot write postmaster.pid because Docker is out of diskFailed to start Docker Application Container Engine.systemctl cannot start the Docker service on Linux