| 字段 | test / interval / timeout / retries / start_period |
|---|---|
| disable | healthcheck: disable: true 关闭 |
| 生效 | docker compose ps 显示 healthy/unhealthy |
示例
示例
services:
web:
image: nginx:1.27-alpine
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost/"]
interval: 10s
timeout: 3s
retries: 3
start_period: 20sstart_period 内的失败不计入重试次数,适合启动慢的应用;健康检查命令要在镜像内真实存在。