Fix and improve

This commit is contained in:
Baohua Yang
2026-02-12 16:51:50 -08:00
parent bae82e993a
commit 0835f8467a
100 changed files with 280 additions and 622 deletions

View File

@@ -2,7 +2,7 @@
数据管理 示意图如下
![](../_images/types-of-mounts.png)
![](./_images/types-of-mounts.png)
这一章介绍如何在 Docker 内部以及容器之间管理数据在容器中管理数据主要有两种方式

View File

@@ -29,8 +29,6 @@ Bind Mount绑定挂载将**宿主机的目录或文件**直接挂载到容
#### 选择建议
具体内容如下
```
需求 推荐方案
─────────────────────────────────────────
@@ -95,8 +93,7 @@ $ docker run -d \
$ echo "Hello" > src/index.html
## 浏览器刷新即可看到变化
具体内容如下:
...
```
#### 场景二配置文件挂载
@@ -329,4 +326,4 @@ $ docker run -v /app/data:/data ...
- [数据卷](volume.md)Docker 管理的持久化存储
- [tmpfs 挂载](tmpfs.md)内存临时存储
- [Compose 数据管理](../compose/10.5_compose_file.md)Compose 中的挂载配置
- [Compose 数据管理](../../10_compose/10.5_compose_file.md)Compose 中的挂载配置

View File

@@ -0,0 +1,35 @@
## tmpfs 挂载
`tmpfs` 挂载会把数据放在宿主机内存中而不是写入容器可写层或数据卷
### 适用场景
- 临时缓存
- 会话数据
- 不希望落盘的敏感中间文件
### 基本用法
```bash
$ docker run --tmpfs /run:rw,noexec,nosuid,size=64m nginx
```
也可以使用 `--mount` 语法
```bash
$ docker run --mount type=tmpfs,destination=/run,tmpfs-size=67108864 nginx
```
### 注意事项
- 容器停止后`tmpfs` 数据会丢失
- `tmpfs` 占用宿主机内存建议显式限制大小
- 不适合需要持久化的数据
### Volume / Bind Mount 对比
| 类型 | 数据位置 | 持久化 | 典型用途 |
|------|---------|-------|---------|
| Volume | Docker 管理目录 | | 数据库长期业务数据 |
| Bind Mount | 宿主机指定目录 | | 开发联调配置文件共享 |
| tmpfs | 内存 | | 高速临时数据敏感临时文件 |

View File

@@ -31,8 +31,6 @@ flowchart LR
#### 容器存储层不推荐存储重要数据
具体内容如下
```mermaid
graph TD
subgraph Container [容器]
@@ -47,8 +45,6 @@ graph TD
#### 数据卷推荐
具体内容如下
```mermaid
graph TD
subgraph Container [容器]
@@ -417,4 +413,4 @@ $ docker volume inspect my-vol
- [绑定挂载](bind-mounts.md)挂载宿主机目录
- [tmpfs 挂载](tmpfs.md)内存中的临时存储
- [存储驱动](../14_implementation/14.4_ufs.md)Docker 存储的底层原理
- [存储驱动](../../14_implementation/14.4_ufs.md)Docker 存储的底层原理