mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-10 20:04:36 +00:00
Fix missing links
This commit is contained in:
@@ -191,15 +191,15 @@ $ docker inspect --format '{{json .State.Health}}' mycontainer | jq
|
||||
|
||||
本节涵盖了相关内容与详细描述,主要探讨以下几个方面:
|
||||
|
||||
#### 1。避免副作用
|
||||
#### 1. 避免副作用
|
||||
|
||||
健康检查会被频繁执行,不要在检查脚本中进行写操作或消耗大量资源的操作。
|
||||
|
||||
#### 2。使用轻量级工具
|
||||
#### 2. 使用轻量级工具
|
||||
|
||||
优先使用镜像中已有的工具 (如 `wget`),避免为了健康检查安装庞大的依赖 (如 `curl`)。
|
||||
|
||||
#### 3。设置合理的 Start Period
|
||||
#### 3. 设置合理的 Start Period
|
||||
|
||||
应用启动可能需要时间 (如 Java 应用)。设置 `--start-period` 可以防止在启动阶段因检查失败而误判。
|
||||
|
||||
@@ -209,7 +209,7 @@ $ docker inspect --format '{{json .State.Health}}' mycontainer | jq
|
||||
HEALTHCHECK --start-period=60s CMD curl -f http://localhost/ || exit 1
|
||||
```
|
||||
|
||||
#### 4。只检查核心依赖
|
||||
#### 4. 只检查核心依赖
|
||||
|
||||
健康检查应主要关注 **当前服务** 是否可用,而不是检查其下游依赖 (数据库等)。下游依赖的检查应由应用逻辑处理。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user