mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-14 13:51:14 +00:00
Fix and improve
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
### 基本语法
|
||||
|
||||
具体内容如下:
|
||||
|
||||
```docker
|
||||
HEALTHCHECK [选项] CMD <命令>
|
||||
HEALTHCHECK NONE
|
||||
@@ -38,8 +36,6 @@ Starting ──成功──> Healthy ──失败N次──> Unhealthy
|
||||
|
||||
#### Web 服务检查
|
||||
|
||||
具体内容如下:
|
||||
|
||||
```docker
|
||||
FROM nginx
|
||||
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
||||
@@ -94,8 +90,6 @@ HEALTHCHECK CMD wget -q --spider http://localhost/ || exit 1
|
||||
|
||||
#### 数据库
|
||||
|
||||
具体内容如下:
|
||||
|
||||
```docker
|
||||
## MySQL
|
||||
|
||||
@@ -108,8 +102,6 @@ HEALTHCHECK CMD redis-cli ping || exit 1
|
||||
|
||||
#### 自定义脚本
|
||||
|
||||
具体内容如下:
|
||||
|
||||
```docker
|
||||
COPY healthcheck.sh /usr/local/bin/
|
||||
HEALTHCHECK CMD ["healthcheck.sh"]
|
||||
@@ -119,7 +111,7 @@ HEALTHCHECK CMD ["healthcheck.sh"]
|
||||
|
||||
### 在 Compose 中使用
|
||||
|
||||
可以在 `docker-compose.yml` 中覆盖或定义健康检查:
|
||||
可以在 `compose.yaml`(或 `docker-compose.yml`)中覆盖或定义健康检查:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
@@ -218,6 +210,6 @@ HEALTHCHECK --start-period=60s CMD curl -f http://localhost/ || exit 1
|
||||
|
||||
### 延伸阅读
|
||||
|
||||
- [CMD 容器启动命令](cmd.md):启动主进程
|
||||
- [Compose 模板文件](../../compose/10.5_compose_file.md):Compose 中的健康检查
|
||||
- [Docker 调试](../../16_appendix/16.2_debug.md):容器排障
|
||||
- [CMD 容器启动命令](7.4_cmd.md):启动主进程
|
||||
- [Compose 模板文件](../10_compose/10.5_compose_file.md):Compose 中的健康检查
|
||||
- [Docker 调试](../16_appendix/16.2_debug.md):容器排障
|
||||
|
||||
Reference in New Issue
Block a user