Re:Show HN: Is_ready – Wait for many services to become avai...
by stavepan on Sunday April 28, 2024 @08:15AM
(#40188040)
That's true.
For example, in the case of PostgreSQL, there is already a tool called pg_isready [0] to do this inside a healthcheck as you described.
services: postgres-db: image: postgres healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"]
application:
image: image
depends_on:
postgres-db:
condition: service_healthy
However, this is not the case for other databases/services.[0] https://www.postgresql.org/docs/current/app-pg-isready.html
In docker compose you can use `depends_on` [0] to define dependencies between containers and by default it will wait until a dependent container is "ready".
But you can also use a more verbose syntax to wait until a container is "healthy", as defined by its own healthcheck.
[0] https://docs.docker.com/compose/compose-file/05-services/#de...