Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add way to healthcheck the docker image #240

Open
CodaBool opened this issue Nov 14, 2023 · 1 comment
Open

Add way to healthcheck the docker image #240

CodaBool opened this issue Nov 14, 2023 · 1 comment

Comments

@CodaBool
Copy link

CodaBool commented Nov 14, 2023

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.)

image

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:

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://
@CodaBool
Copy link
Author

CodaBool commented Nov 14, 2023

just realized the usernames don't match. You don't manage this docker image danielszabo99/microbin do you? 😮‍💨

nvm looks like you are Dániel Szabó. Good to know this is the right place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant