mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-08-10 08:27:25 +00:00
Add new content and update versions
This commit is contained in:
@@ -493,7 +493,14 @@ mac_address: 08-00-27-00-0C-0A
|
||||
```yaml
|
||||
privileged: true
|
||||
```
|
||||
指定容器退出后的重启策略为始终重启。该命令对保持服务始终运行十分有效,在生产环境中推荐配置为 `always` 或者 `unless-stopped`。
|
||||
指定容器退出后的重启策略。该命令对保持服务始终运行十分有效,在生产环境中推荐配置为 `always` 或者 `unless-stopped`。
|
||||
|
||||
| 策略 | 说明 |
|
||||
|------|------|
|
||||
| `no` | 默认值,不自动重启 |
|
||||
| `always` | 无论退出码如何,始终重启;Docker 守护进程启动时也会重启 |
|
||||
| `on-failure[:max-retries]` | 仅在非零退出码时重启,可指定最大重试次数 |
|
||||
| `unless-stopped` | 类似 `always`,但手动停止的容器在守护进程重启后不会自动启动 |
|
||||
|
||||
```yaml
|
||||
restart: always
|
||||
@@ -514,7 +521,33 @@ stdin_open: true
|
||||
tty: true
|
||||
```
|
||||
|
||||
### 11.5.34 读取变量
|
||||
### 11.5.34 `profiles`
|
||||
|
||||
`profiles` 用于按场景选择性启动服务。未指定 `profiles` 的服务默认始终启动;标记了 `profiles` 的服务仅在激活对应 profile 时才启动。
|
||||
|
||||
```yaml
|
||||
services:
|
||||
web:
|
||||
image: nginx
|
||||
|
||||
debug:
|
||||
image: busybox
|
||||
profiles:
|
||||
- debug
|
||||
|
||||
test:
|
||||
image: node
|
||||
profiles:
|
||||
- test
|
||||
```
|
||||
启动时通过 `--profile` 激活:
|
||||
|
||||
```bash
|
||||
$ docker compose --profile debug up # 启动 web + debug
|
||||
$ docker compose up # 仅启动 web
|
||||
```
|
||||
|
||||
### 11.5.35 读取变量
|
||||
|
||||
Compose 模板文件支持动态读取主机的系统环境变量和当前目录下的 `.env` 文件中的变量。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user