My Docker container won't start. Why?

Also searched as: Docker container won't start · Docker container not starting · Docker container stuck in starting

Updated 3 October 2026

Short answer

Run docker logs on the container. Whatever the app printed before it stopped is there. A container exists to run one main process, your app, so "won't start" almost always means the app inside crashed or exited. Usually it's a missing environment variable, a database or service it can't reach, the wrong start command, or an app listening on localhost inside the container, where nothing outside can reach it.

What's the problem

The image builds, but the container exits a second after starting, restarts in a loop, or sits at "starting" and never becomes healthy. Your app is unreachable.

Why it happens

  • The app crashed. The container's main process is the command at the end of the Dockerfile. If that program fails on start, the container stops with it.
  • A setting is missing. Passwords, keys and addresses are passed in as environment variables when the container runs. If they aren't provided, the app reads blanks and fails.
  • It can't reach what it needs. The database address points at localhost, which inside a container means the container itself, not your machine or another container.
  • It's running but unreachable. The app listens on localhost inside the container, so the port you published leads nowhere. It needs to listen on 0.0.0.0.
  • The health check never passes. If the Dockerfile defines a health check, the container reports "starting" until the check succeeds. A wrong check address or a slow start keeps it there.

How to fix it

  1. Read the logs: docker logs <container> shows what the app printed. Look at the last lines before it exited.
  2. Check the exit code with docker ps -a. A code other than 0 means the app failed. Then read the logs again.
  3. Pass in every environment variable the app needs, with -e, an env file, or your compose file.
  4. Fix addresses between containers. Use the other service's name (in Docker Compose, the service name) instead of localhost.
  5. Make the app listen on 0.0.0.0 and the port you publish.
  6. Check the start command (CMD or ENTRYPOINT) runs the right file from the right folder.
  7. If it's stuck at "starting", test the health check command by hand inside the container.

When to call Preventionlabs

If the logs point at one missing setting, fix it and you're running. Call us when the container setup was built by someone who's gone, nothing is documented, and every fix reveals another missing piece. A resurrection gets the app running in your own hosting account, with the user flows you list working end to end, and hands it back with notes on how to run and deploy it.

Submit your project for a free assessment

Free assessment. $10,000 AUD flat to get it live, only if we take it on and you go ahead.

Sources

  1. Docker: Run multiple processes in a containerofficial docsA container's main running process is the ENTRYPOINT and/or CMD at the end of the Dockerfile.
  2. Docker: docker container logsofficial docsThe docker logs command batch-retrieves logs present at the time of execution.
  3. Docker: Dockerfile reference: HEALTHCHECKofficial docsWhen a container has a healthcheck specified, it has a health status in addition to its normal status. This status is initially starting.
  4. Render: Web Services: Port bindinghosting platform docsEvery Render web service must bind to a port on host 0.0.0.0 to serve HTTP requests.
← All of It used to work