traefik / whoami

Tiny Go server that prints os information and HTTP request to output
https://traefik.io
Apache License 2.0
1.04k stars 223 forks source link

HEALTH CHECK not working #93

Open mikaelparkefelt opened 2 months ago

mikaelparkefelt commented 2 months ago

I would like you add the possibility to add a HEALTH CHECK when running this container with a compose file.

Would this be possible to do that? or tell me what the syntax is int he compose file to get a health check.

jonasgeiler commented 1 month ago

It currently isn't possible since the whoami Docker image is based on "scratch", which is basically a completely empty operating system. So no curl included.

It think it would be pretty easy to add a flag which, when enabled, just does a health check. So you'd just run the /whoami -healthcheck command and it does the request. I also described this in #81.

mikaelparkefelt commented 1 month ago

So in the compose file I add command: /whoami --healthcheck insted of the default one?

jonasgeiler commented 1 month ago

@mikaelparkefelt wrote: So in the compose file I add command: /whoami --healthcheck insted of the default one?

You WOULD but it's currently not implemented!

mikaelparkefelt commented 1 month ago

So what exactly should i do then to get healthcheck to work?

jonasgeiler commented 1 month ago

@mikaelparkefelt wrote: So what exactly should i do then to get healthcheck to work?

At the moment there is not much you can do, except modify the container yourself, and f.e. inject the curl binary into it with a bind mount. Maybe I'll work on a PR which implements a healthcheck feature, though.

Here's how you could do it: docker run --rm --name whoami -v /usr/bin/curl:/curl --health-cmd '/curl --fail http://localhost:80/health' traefik/whoami