netbox-docker-agent icon indicating copy to clipboard operation
netbox-docker-agent copied to clipboard

:sparkles: Healthcheck and `depends_on`

Open linkdd opened this issue 1 year ago • 4 comments

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:

Image

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 avatar Mar 28 '25 11:03 linkdd

@linkdd do you have in mind a proposal for the plugin requests ? Would you keep the same property name ?

lvenier avatar Mar 31 '25 08:03 lvenier

@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?

linkdd avatar Mar 31 '25 09:03 linkdd

Is it possible on the same host that container A depends on container B and container B depends on container A?

fanshan avatar May 06 '25 12:05 fanshan

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.

linkdd avatar May 06 '25 12:05 linkdd