Dockerfile instructions

Dockerfile HEALTHCHECK

Runs a container probe. Interval, timeout, retries and optional start period govern status transitions. Probe exit 0 succeeds, 1 fails, 2 is reserved. NONE disables inherited health checks. Health alone does not restart standalone containers. Observe healthy before removing the marker; inspect failed probe history and running unhealthy before cleanup.

Formal Syntax & Structure

docker syntaxdocker
HEALTHCHECK [OPTIONS] CMD <command> | HEALTHCHECK NONE

Parameters & Attributes

NameTypeDescription
commandstringProbe command.
--intervalstringTime between probes.
--timeoutstringProbe time limit.
--retriesstringConsecutive failures threshold.
--start-periodstringOptional startup grace period.

Working Example

Example Snippetdocker
FROM busybox:1.37RUN touch /readyHEALTHCHECK --interval=2s --timeout=1s --retries=2 CMD test -f /ready || exit 1CMD ["sleep", "120"]
Docker Reference