mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-08-10 16:37:34 +00:00
Add new content and update versions
This commit is contained in:
@@ -186,4 +186,14 @@ HEALTHCHECK --start-period=60s CMD curl -f http://localhost/ || exit 1
|
||||
|
||||
健康检查应主要关注 **当前服务** 是否可用,而不是检查其下游依赖 (数据库等)。下游依赖的检查应由应用逻辑处理。
|
||||
|
||||
#### 5. 与容器编排平台的关系
|
||||
|
||||
不同平台对 HEALTHCHECK 的支持有所不同:
|
||||
|
||||
- **Docker Compose**:直接使用 Dockerfile 中定义的 HEALTHCHECK,也可在 `compose.yaml` 中覆盖
|
||||
- **Docker Swarm**:使用 HEALTHCHECK 进行服务健康判断和滚动更新决策
|
||||
- **Kubernetes**:**忽略** Dockerfile 中的 HEALTHCHECK,使用自己的 `livenessProbe` 和 `readinessProbe` 机制
|
||||
|
||||
如果应用同时部署在 Docker Compose 和 Kubernetes 环境中,建议在 Dockerfile 中保留 HEALTHCHECK(供 Compose 使用),同时在 Kubernetes 的 Pod 配置中定义对应的探针。
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user