The postgres images provide an RDBMS which is usually a dependency of other services. The Compose depends_on attribute allows to express that, but its conditions attribute defaults to service_started, which does not work properly (the dependency is satisfied too early).
Lots of webpages deal with that issue, such as the docker-compose-healthcheck project, usually suggesting the service_healthy condition instead. It would be great to either provide a proper/reliable way for PostgreSQL to signal dependents that it is actually started, or at least mitigate by documenting the best way to workaround.