Docker healthchecks are minor but a nice to have. Services like AWS ECS make good use of them. The result shows in docker ps. I don't personally use portainer but I know it's common for self-host and it appears like they also make use of it in their UI, related. I personally use them in my selfhost machine with the lazydocker CLI
how
I have experience in this area (contributed to adding healthchecks to other self-host projects immich, cloudflare tunnel, and microbin) and can help contribute. There are generally two approaches people take for something like this:
create a script or endpoint
add a tool, like netcat for basic Docker healthchecks
I recommend option 1 to minimize bloat. You already have curl in the image so just need either add script that can be ran using bash to hit the endpoint. Or if one already exists write a one-liner with curl to hit the endpoint.
you can actually add the default healthcheck behavior into the Dockerfile and then people won't have to add extra lines to their docker-compose
Other considerations
if your image is not ready for it this can add junk logs
if you for some reason switch to a slimmer base image at some point curl/whatever CLI might not exist
I think a possible solution might be to connect to rcon since that should always be running. I'm just not sure if you have a rcon client already on the image that can be used (if you do that seems like a clean approach, maybe even having it attempt a console command like /players count or /time to verify the server is running).
could probably copy the approach that the most popular minecraft image takes. Which makes a lot of sense since this image isn't a web server (curl might be useless). Their image is also a UDP service with a side RCON service. Here is their Dockerfile code which runs a bash script here
EDIT: looking into this further the minecraft image describes here that they have a Golang static binary built just for querying the health of a minecraft server baked into the image. I did a static binary approach for microbin but it's generally an overkill for what healthchecks are. But if your already doing something similar it could work 🤷
why
Docker healthchecks are minor but a nice to have. Services like AWS ECS make good use of them. The result shows in
docker ps
. I don't personally useportainer
but I know it's common for self-host and it appears like they also make use of it in their UI, related. I personally use them in my selfhost machine with the lazydocker CLIhow
I have experience in this area (contributed to adding healthchecks to other self-host projects immich, cloudflare tunnel, and microbin) and can help contribute. There are generally two approaches people take for something like this:
netcat
for basic Docker healthchecksI recommend option 1 to minimize bloat. You already have curl in the image so just need either add script that can be ran using bash to hit the endpoint. Or if one already exists write a one-liner with curl to hit the endpoint.
Other considerations