Skip to content

feat(linux): add HEALTHCHECK instruction#2249

Open
amdadulbari wants to merge 5 commits intojenkinsci:masterfrom
amdadulbari:topic/add-healthchecks
Open

feat(linux): add HEALTHCHECK instruction#2249
amdadulbari wants to merge 5 commits intojenkinsci:masterfrom
amdadulbari:topic/add-healthchecks

Conversation

@amdadulbari
Copy link

Added HEALTHCHECK instruction to the alpine, debian, and rhel controller Dockerfiles to improve container orchestration and monitoring reliability. The healthcheck verifies that the Jenkins login page is accessible.

Testing done

Validated that the docker build command successfully parses the Dockerfiles with the new HEALTHCHECK instruction.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@amdadulbari amdadulbari requested a review from a team as a code owner February 6, 2026 10:19
Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the /health endpoint instead of /login. It was added in Jenkins 2.506. You can read more about the /health endpoint in issue:

Please test that the controller starts and runs as expected. Testing that docker build completes successfully is necessary, but not sufficient for this pull request.

@amdadulbari amdadulbari force-pushed the topic/add-healthchecks branch from 72e6a1c to 4315a17 Compare February 6, 2026 11:04
@amdadulbari
Copy link
Author

Please use the /health endpoint instead of /login. It was added in Jenkins 2.506. You can read more about the /health endpoint in issue:

Please test that the controller starts and runs as expected. Testing that docker build completes successfully is necessary, but not sufficient for this pull request.

Thank you for the feedback! I have updated the HEALTHCHECK instruction to use the /health endpoint as requested.

I have also verified that the controller starts up correctly and the health check works as expected.

Here is the verification summary:

Controller Startup:

  • Confirmed logs show Jenkins is fully up and running.
  • Health Check Status: docker inspect reports "Status": "healthy".
  • Endpoint Response: curl http://localhost:8080/health returns 200 OK with {"status":true}.

The changes have been pushed.

@lemeurherve
Copy link
Member

lemeurherve commented Feb 6, 2026

Is it possible to have this HEALTHCHECK in Windows images too?

Is it possible to put those HEALTHCHECKs more closer to the bottom of Dockerfiles?

@amdadulbari
Copy link
Author

Is it possible to have this HEALTHCHECK in Windows images too?

Is it possible to put those HEALTHCHECKs more closer to the bottom of Dockerfiles?

As requested, I’ve moved the HEALTHCHECK instructions to the bottom of the Dockerfiles for the Linux images.
I’m keeping this PR scoped to the Linux variants for now, since I’m currently working on a non-Windows machine.

@amdadulbari
Copy link
Author

@lemeurherve Thanks for the feedback. Updated accordingly.

@lemeurherve lemeurherve changed the title feat: Add HEALTHCHECK instruction to controller Dockerfiles feat(linux): Add HEALTHCHECK instruction Feb 6, 2026
@lemeurherve lemeurherve changed the title feat(linux): Add HEALTHCHECK instruction feat(linux): add HEALTHCHECK instruction Feb 6, 2026
@dduportal
Copy link
Contributor

FTR, there has been discussion years ago about adding HEALTHCHECK in the Dockerfile vs. only documenting it.

This feature is not really portable:

  • It does NOT work with other container engine or orchestrators than Docker CE (not on Podman, not on Kubernetes, etc.). Creating a feature which is "Docker-only" may create false expectations for end users. Hence the suggestion (which was never followed up years ago) to document the health check instead, with a docker-compose example
  • Also, the healthcheck feature executes commands inside the container, eg. creates dependency on the binary used (here it is curl). What if curl is removed from the main image for instance?

@amdadulbari
Copy link
Author

FTR, there has been discussion years ago about adding HEALTHCHECK in the Dockerfile vs. only documenting it.

This feature is not really portable:

  • It does NOT work with other container engine or orchestrators than Docker CE (not on Podman, not on Kubernetes, etc.). Creating a feature which is "Docker-only" may create false expectations for end users. Hence the suggestion (which was never followed up years ago) to document the health check instead, with a docker-compose example

  • Also, the healthcheck feature executes commands inside the container, eg. creates dependency on the binary used (here it is curl). What if curl is removed from the main image for instance?

This PR is intentionally Docker-scoped to improve the Docker-native experience (docker ps / docker inspect) and does not aim to define a portable or orchestrator-level health signal. While Docker-only, HEALTHCHECK is a well-established convention and provides immediate value for users running Jenkins directly with Docker.

Regarding the curl dependency: it’s lightweight, not part of Jenkins’ functional path, and if it’s ever removed the health check can be trivially adjusted without impact. I’m happy to add a short note clarifying these assumptions if needed.

@timja
Copy link
Member

timja commented Feb 6, 2026

and if it’s ever removed the health check can be trivially adjusted without impact. I’m happy to add a short note clarifying these assumptions if needed.

How? Adding the dependency on curl here makes it harder to remove it.

@amdadulbari
Copy link
Author

and if it’s ever removed the health check can be trivially adjusted without impact. I’m happy to add a short note clarifying these assumptions if needed.

How? Adding the dependency on curl here makes it harder to remove it.

To completely avoid the dependency on curl, I could implement a lightweight Java-based health check that relies solely on the JRE already present in the image. Would you prefer I switch to that approach?

@lemeurherve
Copy link
Member

lemeurherve commented Feb 13, 2026

Still not really convinced.

Can you open an issue explaining in which context and why the Jenkins controller image would need this healthcheck requiring an additional dependency (IOW increasing maintainance burden) please?

Note: It's already configurable from the Jenkins helm chart:
https://github.com/search?q=repo%3Ajenkinsci%2Fhelm-charts%20health&type=code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants