The app container never settles — docker ps keeps flipping it between Restarting and gone. The database db next to it is up and healthy. The app was deployed minutes ago and has already restarted more than a dozen times. Find out why it can't stay up and get it running.
app — myapp:v1.2.3, Restarting, restarted many times.db — postgres:15, Up, healthy, listening on 5432.$ docker ps -a
CONTAINER ID IMAGE STATUS NAMES
cafef00d1234 myapp:v1.2.3 Restarting (1) ... app
0d1e2f3a4b5c postgres:15 Up 8 minutes db
$ docker inspect -f '{{.RestartCount}}' app
14
$ docker logs app
psycopg2.OperationalError: could not translate host name "postgres" to
address: Name or service not known
You've solved it when:
RestartCount, and logs that show the app failing to
reach its database at host postgres — but the actual database
container is named db. The DB is healthy; the app's DATABASE_URL
points at the wrong host.
app running by pointing it at the real database hostdb) — e.g. recreate it with a corrected DATABASE_URL.
docker CLI only.app in status == running, pointed at the db host.RestartCount (not just the latest STATUS) the signal thatDATABASE_URL is postgres, the container is db —