{"id":16893683,"url":"https://github.com/uded/docker-healthcheck-java","last_synced_at":"2025-07-23T19:03:38.966Z","repository":{"id":137437414,"uuid":"133092576","full_name":"uded/docker-healthcheck-java","owner":"uded","description":null,"archived":false,"fork":false,"pushed_at":"2018-11-03T20:06:45.000Z","size":20,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T05:32:03.041Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uded.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-11T22:01:52.000Z","updated_at":"2022-01-13T07:34:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"f89db14f-5fa7-4aa3-9549-39f559b935cf","html_url":"https://github.com/uded/docker-healthcheck-java","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/uded/docker-healthcheck-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uded%2Fdocker-healthcheck-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uded%2Fdocker-healthcheck-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uded%2Fdocker-healthcheck-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uded%2Fdocker-healthcheck-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uded","download_url":"https://codeload.github.com/uded/docker-healthcheck-java/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uded%2Fdocker-healthcheck-java/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266737568,"owners_count":23976389,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T17:16:00.005Z","updated_at":"2025-07-23T19:03:38.933Z","avatar_url":"https://github.com/uded.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Java Docker health check app\n\nDocker, since verions 1.12 or so, have a neat feature to run a health check on a container. \n\n#### Great! Let's do it with `curl` or `iwr`\nHealt check is a really simple thing to implement. You call a service, and it should `0` if it works and `1` if it does\nnot. Simple? Sure, even Docker dockumentation will tell you how to do it with HTTP based service using `curl`:\n\n```docker\nHEALTHCHECK --interval=5m --timeout=3s \\\n  CMD curl -f http://localhost/ || exit 1\n```\n\nHere, every 5 minutes with a timeout of 3 seconds `localhost` will be called. Using `curl`. On Windows, using IWR, it's\na bit more complicate, but still - it works. It's simple in the end. Right? \n\nSo why this lib?\n\n#### The problem with `curl` and `iwr`\n1. In Linux images, you need to have curl installed. You can start `FROM` alpine and have a 4MB base image. But guess \nwhat - it doesn't come with `curl` pre-installed. So you need to add `RUN apk --update --no-cache add curl`. Sure, \nno sweat, easy to do. That will add a new layer of 2.5MB to the image. And additional headaches of curl and libraries. \n2. In Windows images, you need to have PowerShell installed. But recent Nano images will not have it. To save space. \nMakes sense, right?\n3. If you choose any of the above you loose portability. Different scripts for health-checks depending on the platform. \nSure, no biggie... but what for? You have Java installed already. You had to install it. Or find an image that have Java\nsince your app will rely on it. Right? Let's use it...\n\n### Here comes the solution\nA simple library. \u003c100kb. You run it as a Java command line app. Yes, it has to start up Java... but that is not really \na huge deal nowadays.\n\nTo include it in your Docker image simply download the latest release from Github:\n\n```bash\nwget https://github.com/uded/docker-healthcheck-java/releases/download/healthcheck-1.0/healthcheck.jar\n``` \n\n*OR* if you're running maven:\n\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003ecom.googlecode.maven-download-plugin\u003c/groupId\u003e\n    \u003cartifactId\u003edownload-maven-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e1.4.0\u003c/version\u003e\n    \u003cexecutions\u003e\n        \u003cexecution\u003e\n            \u003cid\u003einstall-healthcheck\u003c/id\u003e\n            \u003cphase\u003egenerate-resources\u003c/phase\u003e\n            \u003cgoals\u003e\n                \u003cgoal\u003ewget\u003c/goal\u003e\n            \u003c/goals\u003e\n            \u003cconfiguration\u003e\n                \u003curl\u003ehttps://github.com/uded/docker-healthcheck-java/releases/download/healthcheck-1.0/healthcheck.jar\u003c/url\u003e\n                \u003cunpack\u003efalse\u003c/unpack\u003e\n                \u003coutputFileName\u003ehealthcheck.jar\u003c/outputFileName\u003e\n                \u003coutputDirectory\u003e${project.build.directory}/lib\u003c/outputDirectory\u003e\n            \u003c/configuration\u003e\n        \u003c/execution\u003e\n    \u003c/executions\u003e\n\u003c/plugin\u003e\n```\n\nAdd it to your image and then add a `HEALTHCHECK` command ass well:\n\n```docker\nADD target/lib/healthcheck.jar healthcheck.jar\nHEALTHCHECK CMD java -jar {PATH_TO}/healthcheck.jar http://localhost:8080/actuator/health\n```\n\nThat's it! By default every 30 seconds this simple JAR will fire up and request given Spring Boot URL and report back \nthe result of such a query... ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuded%2Fdocker-healthcheck-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuded%2Fdocker-healthcheck-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuded%2Fdocker-healthcheck-java/lists"}