Docker images use tools inside the image to perform healthchecks.
Healthchecks are a nice feature to support since cloud hosting (AWS ECS) and selfhostings (myself with lazydocker) commonly use this feature to determine if the service is healthy from internal reporting.
Since curl and wget are not present I tried to use nc which also was also not present. I think one of these three CLI tools should be built into the image to allow for healthchecking on port 8080.
Wget is a lighter choice over curl at 2.5Mb but not compared to netcat. However, chatgpt suggested it would be more secure
chatgpt (chatgpt generally scores really well on networking / sys admin tests, so I'm using it as a source.)
If size is the concern then nc seems the lightest (66Kb)
Here is how a healthcheck would be done with each of those CLI tools:
Docker images use tools inside the image to perform healthchecks.
Healthchecks are a nice feature to support since cloud hosting (AWS ECS) and selfhostings (myself with lazydocker) commonly use this feature to determine if the service is healthy from internal reporting.
Since
curl
andwget
are not present I tried to usenc
which also was also not present. I think one of these three CLI tools should be built into the image to allow for healthchecking on port 8080.Wget is a lighter choice over curl at 2.5Mb but not compared to netcat. However, chatgpt suggested it would be more secure
If size is the concern then
nc
seems the lightest (66Kb)Here is how a healthcheck would be done with each of those CLI tools:
nc -z 127.0.0.1 8080 || exit 1
curl --fail http://localhost:8080 || exit 1
wget --no-verbose --tries=1 --spider http://localhost:8080 || exit 1
Once one of those is able to pass you can add them to a docker compose yaml file like below: