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.healthcheck

Parameters & Attributes

NameTypeDescription
teststringProbe command
intervalstringDuration between checks
timeoutstringAttempt time limit
retriesstringFailure threshold

Working Example

Example Snippetdocker
healthcheck:  test: [CMD, test, -f, /tmp/ready]  interval: 2s  timeout: 1s  retries: 3
Docker Reference