HEALTHCHECK tests a running container; Compose reuses the same defaults
Answer: The Dockerfile HEALTHCHECK instruction tells Docker how to test a running container. The form is HEALTHCHECK [OPTIONS] CMD command, or HEALTHCHECK NONE to disable a check inherited from the base image. A container with a check has a status of starting, then healthy after a pass, then unhealthy after a configured number of consecutive failures. There can be only one HEALTHCHECK instruction; the last one wins. Exit status 0 means success, 1 means the container is not working correctly.
Compose healthcheck declares the same kind of check for a service and uses the same default values as the Dockerfile instruction.
See also
Claims
- id: C1 claim: HEALTHCHECK tells Docker how to test a container. source: S1 evidence: "The HEALTHCHECK instruction tells Docker how to test a container"
- id: C2 claim: A Dockerfile may have only one effective HEALTHCHECK. source: S1 evidence: "There can only be one HEALTHCHECK instruction in a Dockerfile."
- id: C3 claim: Compose healthcheck determines whether service containers are healthy. source: S2 evidence: "
healthcheckdeclares a check that's run to determine whether"
- id: C4 claim: Compose uses the same default values as the Dockerfile instruction. source: S2 evidence: "It works in the same way, and has the same default values, as the"
Sources
- [S1] Dockerfile reference: HEALTHCHECK. Docker Docs. https://docs.docker.com/reference/dockerfile/#healthcheck . License: Apache-2.0. Accessed 2026-11-16.
- [S2] Compose specification: healthcheck. compose-spec/compose-spec (GitHub). https://github.com/compose-spec/compose-spec/blob/main/spec.md . License: Apache-2.0. Accessed 2026-11-16.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker Docs, Dockerfile reference: HEALTHCHECK, Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Docker docs; Docker name and logo are trademarks of Docker Inc and are not licensed; compose-spec/compose-spec (GitHub), Compose specification: healthcheck, Apache-2.0 (https://raw.githubusercontent.com/compose-spec/compose-spec/master/LICENSE). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker Docs, Dockerfile reference: HEALTHCHECK, Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Docker docs; Docker name and logo are trademarks of Docker Inc and are not licensed; compose-spec/compose-spec (GitHub), Compose specification: healthcheck, Apache-2.0 (https://raw.githubusercontent.com/compose-spec/compose-spec/master/LICENSE).
Cite this
iinventedlight. 2026. "HEALTHCHECK tests a running container; Compose reuses the same defaults." iinventedlight Library, iil:note:j108w51e, version of 2026-11-16. https://iinventedlight.com/library/notes/docker-healthcheck/. License: CC-BY-4.0.
@misc{iil_note_j108w51e,
author = {{iinventedlight}},
title = {{HEALTHCHECK tests a running container; Compose reuses the same defaults}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-16},
url = {https://iinventedlight.com/library/notes/docker-healthcheck/},
note = {Permanent ID iil:note:j108w51e. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-healthcheck.md.