:sparkles: Healthcheck and `depends_on`
Context
Dockerfiles can have the HEALTHCHECK directive (see documentation), and the Docker Engine API has a Healthcheck field when creating a container to override the container's healthcheck:
When set, the container's status will remain in starting until the check succeeds, and the container's status becomes healthy. If the healthcheck fails until the start period is expired, the status become unhealthy.
This allows Docker Compose to implement the depends_on property to wait for other containers to be healthy (or running if no healthcechk is set).
Feature Request
The agent should allow the user to set the container's healthcheck (because not many Docker images use the HEALTHCHECK directive), and then provide a depends_on field to wait for dependencies to be healthy or running.
@linkdd do you have in mind a proposal for the plugin requests ? Would you keep the same property name ?
@lvenier I think the Healthcheck could be a model, and the Container model would have a nullable One-to-One relationship. Then the depends_on field on the Container model would be a Many-to-Many to Container and would be filtered by the container's host (as it does not make sense to depend on a container from another host).
@fanshan What do you think?
Is it possible on the same host that container A depends on container B and container B depends on container A?
services:
foo:
image: nginx:latest
depends_on:
- bar
bar:
image: nginx:latest
depends_on:
- foo
Then:
$ docker compose up
dependency cycle detected: bar -> foo -> bar
So no.