Proposition for an official Docker Compose Guide

The depends_on option is deprecated since docker-compose version 3 because depends_on only checks whether the dependent container is started, but does not check whether the dependent service (e.g. PostgreSQL server) is ready to accept requests.

It’s better to use something like wait-for-it (GitHub - vishnubob/wait-for-it: Pure bash script to test and wait on the availability of a TCP host and port · GitHub) to wait for a port to open.