Multiple Container same loadbalance healtcheck how is happen?

Hello,

We've been discussing how to set up a load balancer for multiple identical containers. You can find the discussion thread here: link.

Now, I'm interested in adding a health check to the path /. If it returns a 200 status code, it indicates that the service is healthy.

frontend1:
  labels:
    - traefik.enable=true
    - traefik.http.routers.frontendsite.rule=Host(`foobar.com`) || Host(`www.foobar.com`)
    - traefik.http.services.frontendsite.loadbalancer.server.port=3001
    - traefik.docker.network=supabase

frontend2:
  labels:
     - traefik.enable=true
     - traefik.http.services.frontendsite.loadbalancer.server.port=3001
     - traefik.docker.network=supabase

I find the documentation on this topic a bit unclear. Do I need to add health check tags to all containers, or is it enough to add them to the main container?

Thank you.

@bluepuma77

Healthcheck is usually a Docker feature, so you add it to Dockerfile or docker-compose.yml.

Traefik will recognize "healthy" containers.

Hello,
I see like that tags on documentation what this traefik tags use for then ?

    - "traefik.http.services.myapp.loadbalancer.passhostheader=true"
    - "traefik.http.services.myapp.loadbalancer.healthcheck.path=/healthcheck"
    - "traefik.http.services.myapp.loadbalancer.healthcheck.interval=100ms"
    - "traefik.http.services.myapp.loadbalancer.healthcheck.timeout=75ms"
    - "traefik.http.services.myapp.loadbalancer.healthcheck.scheme=http"

Thank you.

You can also define a Traefik internal healthcheck for services (doc).

But this way your orchestrator doesn’t see the health status, that’s why I mentioned the Docker healthcheck, which will also be considered by Traefik.