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 NONEParameters & Attributes
| Name | Type | Description |
|---|---|---|
| command | string | Probe command. |
| --interval | string | Time between probes. |
| --timeout | string | Probe time limit. |
| --retries | string | Consecutive failures threshold. |
| --start-period | string | Optional 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"]