microbin
microbin copied to clipboard
Add way to healthcheck the docker image
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:
nc -z 127.0.0.1 8080 || exit 1curl --fail http://localhost:8080 || exit 1wget --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:
example using wget
version: "3.9"
services:
microbin:
container_name: microbin
image: danielszabo99/microbin
restart: unless-stopped
ports:
- 8080:8080
volumes:
- ./data:/app/microbin_data
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:8080 || exit 1
environment:
MICROBIN_ADMIN_USERNAME=
MICROBIN_ADMIN_PASSWORD=
MICROBIN_PUBLIC_PATH=https://
~~just realized the usernames don't match. You don't manage this docker image danielszabo99/microbin do you?~~ :face_exhaling:
nvm looks like you are Dániel Szabó. Good to know this is the right place.