Files
nexus/wiki/concepts/Bind-Mount.md

29 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
id: Bind-Mount
title: "Bind Mount"
type: concept
tags: [docker, storage, development]
sources: []
last_updated: 2026-04-15
---
## Definition
Bind Mount绑定挂载是 Docker 的一种存储卷类型,将宿主机文件系统上的特定目录/文件直接映射到容器内,容器内对此路径的读写操作直接作用于宿主机文件系统,实现代码修改实时生效。
## vs Named Volume
| 维度 | Bind Mount | Named Volume |
|------|-----------|-------------|
| 数据位置 | 宿主机任意路径 | Docker 管理(/var/lib/docker/volumes |
| 适用场景 | 开发(代码热更新) | 生产(数据持久化) |
| 可移植性 | 依赖宿主机路径 | Docker 自动管理 |
| 备份 | 随宿主机备份 | 需单独备份 |
## Use Case
- 开发环境:宿主机源码目录挂载到容器内,修改文件无需重建镜像
- 生产环境:使用 Named Volume 或直接使用 Synology NAS 存储路径
## Related Concepts
- [[Docker Compose]]:定义 Bind Mount 的方式
- [[Docker Attach模式]]Attach 模式适合 Bind Mount 开发
- [[Synology NAS]]NAS 存储路径直接挂载到容器(/volume1/docker/...