docs icon indicating copy to clipboard operation
docs copied to clipboard

Add Health Check Example for Self-Hosted Directus in Docker

Open podlomar opened this issue 1 year ago • 5 comments

Describe the Request

When self-hosting a Directus instance using Docker, it's common to have another container running on top of Directus as part of a larger application stack. This app container often needs to wait until Directus is fully up and ready before starting.

A working health check that I use looks like this:

healthcheck:
      test: ["CMD", "wget", "--spider", "-q", "http://directus:8055/server/health"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_interval: 5s
      start_period: 30s

I suggest adding this example to the Directus documentation to help others avoid the trial-and-error process of figuring out a proper health check setup.

Maintenance Strategy

Unlikely to require frequent maintenance as long as the health API endpoint stays the same and the directus container contains wget by default.

podlomar avatar Feb 05 '25 20:02 podlomar

I would like to be assgined to this issue. It's my first, so not sure if this comment is enough...

podlomar avatar Feb 05 '25 20:02 podlomar

@podlomar feel free to create a PR to the docs repo and thank you very much for wanting to improve our docs. ❤

Nitwel avatar May 06 '25 10:05 Nitwel

Directus may report as unhealthy if, for instance, the EMAIL_CONNECTION is missing. In this case the response is a 503. In my case I only need to check whether the HTTP server is accepting requests to be considered healthy, hence the /server/ping endpoint suits me better.

services:
  directus:
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "[ $$(wget -q -O - http://directus:8055/server/ping) = 'pong' ]",
        ]
      interval: 30s
      timeout: 5s
      retries: 5
      start_interval: 5s
      start_period: 30s

hichamelkaddioui avatar Aug 15 '25 00:08 hichamelkaddioui