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

About Docker HEALTHCHECK again #1350

Open
alex-arana opened this issue Jun 26, 2023 · 6 comments
Open

About Docker HEALTHCHECK again #1350

alex-arana opened this issue Jun 26, 2023 · 6 comments

Comments

@alex-arana
Copy link

Following up on Issue #183 regarding implementation of Docker HEALTHCHECK within a distroless image, the accepted solution no longer appears to work.

As per one of the closing comments back in March, adding wget to a distroless image could be used to implement Docker HEALTHCHECK like so:

COPY --from=busybox:1.36.0-musl /bin/wget /usr/bin/wget

However, this does not appear to work with the following distroless container images I have tested:

  • gcr.io/distroless/base:latest
  • gcr.io/distroless/base:nonroot

Has anyone else encountered this issue?

@loosebazooka
Copy link
Member

I think more information is needed here. What doesn't work? Is it not putting the wget binary in the container? or is your healthcheck failing for some other reason?

@alex-arana
Copy link
Author

Sure. I've created a small Java/Kotlin application to demonstrate the issue:

https://github.com/alex-arana/demo

The project creates a Docker image out of a Kotlin Spring Boot app using a distroless base and packages wget executable to implement Docker HEALTHCHECK as discussed. Creating and running a local container using docker-compose usually becomes unhealthy after a couple of minutes.

@alex-arana
Copy link
Author

I've added a branch called openjdk17-base-working to the demo repository which implements a working version of the Docker HEALTHCHECK.

The only difference with the non-working version of the same project is using an openjdk:17 based image instead of a distroless image.

@jbergstroem
Copy link

What I've seen in very minimal images for healtchecks is invoking the language runtime for doing a http request. Check this supabase container for instance:

https://github.com/supabase/supabase/blob/fde963b239d4fb8cc014d710ebb82641876609db/docker/docker-compose.yml#L14-L22

@gblandinkingland
Copy link

I've also come across this issue. I ran with a debug image to try and get a better idea of what was going on, and it seems that wget gives a "Bad system call" response.

@eifinger
Copy link

Based on @jbergstroem comment I succesfully implemented that for Java/Kotlin:
https://github.com/eifinger/distroless-healthcheck

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

5 participants