Skip to content

fix(docker): use JSON notation for HEALTHCHECK CMD (hadolint DL3025) - #52

Merged
guillaume-sainthillier merged 1 commit into
mainfrom
fix/hadolint-dl3025-json-healthcheck
Sep 16, 2026
Merged

guillaume-sainthillier merged 1 commit into
mainfrom
fix/hadolint-dl3025-json-healthcheck

Conversation

@guillaume-sainthillier

Copy link
Copy Markdown
Member

hadolint-action 3.5.0 (PRs #49 / #51) ships a newer hadolint that enforces DL3025 on the HEALTHCHECK instructions, producing 36 warnings and failing lint-dockerfiles on every open PR (failure-threshold: warning).

All 36 Dockerfiles are converted to JSON notation:

-    CMD curl -f http://localhost/_health || exit 1
+    CMD ["/bin/sh", "-c", "curl -f http://localhost/_health || exit 1"]

The shell is kept explicitly rather than using a bare exec form (CMD ["curl", "-f", ...]) because || exit 1 normalises the exit status. Docker's healthcheck contract reserves exit code 2, and bare curl -f can exit 2, 7, 22 or 28 — so dropping the shell would subtly change healthcheck behaviour.

Verified locally: hadolint --failure-threshold warning */Dockerfile exits 0, and docker build --check reports no warnings.

hadolint-action 3.5.0 ships a newer hadolint that enforces DL3025 on the
HEALTHCHECK instructions, failing CI on every open PR.

The shell form is wrapped in an explicit /bin/sh -c rather than converted to
a bare exec form, because '|| exit 1' normalises curl's exit status to 1.
Docker reserves healthcheck exit code 2, and bare 'curl -f' can return 2, 7,
22 or 28, so dropping the shell would change healthcheck semantics.
@guillaume-sainthillier
guillaume-sainthillier merged commit ef1107a into main Sep 16, 2026
24 checks passed
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

Successfully merging this pull request may close these issues.

1 participant