match4everyone / match4healthcare

Helping hospitals find qualified medicine students (Hackathon #wirvsvirus). A more flexibel version is currently in development under match4everyone/match4everything,
https://match4healthcare.de
Other
17 stars 10 forks source link

docker-compose up fails when the database container is not (yet) started #526

Open maltezacharias opened 4 years ago

maltezacharias commented 4 years ago

Describe the bug When db container is not running the main app container will stop

To Reproduce Steps to reproduce the behavior:

  1. Introduce a config change that will cause the database to fail to come up
  2. run docker-compose up or deploy.sh
Error 
 django.db.utils.OperationalError: could not translate host name "database" to address: Name or service not known

Expected behavior the main app container should wait for the database to become available:

The problem of waiting for a database (for example) to be ready is really just a subset of a much larger problem of distributed systems. In production, your database could become unavailable or move hosts at any time. Your application needs to be resilient to these types of failures.

(Docs on https://docs.docker.com/compose/startup-order/)

Additional context The script should indicate clearly that it's waiting for the database to come up. In Build environments it should probably timeout after a while?