Docker Compose
Compose healthcheck
Run a bounded in-container test; health differs from process state. CMD uses an argument list, CMD-SHELL uses shell evaluation. interval, timeout, retries and start_period control probe scheduling and failure accounting. Use bounded observation; a running process and health status are different evidence.
Formal Syntax & Structure
docker syntaxdocker
services.SERVICE.healthcheckParameters & Attributes
| Name | Type | Description |
|---|---|---|
| test | string | Probe command |
| interval | string | Duration between checks |
| timeout | string | Attempt time limit |
| retries | string | Failure threshold |
Working Example
Example Snippetdocker
healthcheck: test: [CMD, test, -f, /tmp/ready] interval: 2s timeout: 1s retries: 3