|
|
|
|
|
by tommasoamici
778 days ago
|
|
>Feels like something very similar should be built into tools like docker-compose. 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. services:
web:
depends_on:
db:
condition: service_healthy
db:
image: postgres
[0] https://docs.docker.com/compose/compose-file/05-services/#de... |
|
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"]
However, this is not the case for other databases/services.[0] https://www.postgresql.org/docs/current/app-pg-isready.html