Files
nexus/wiki/concepts/Bind-Mount.md
2026-04-17 08:38:12 +08:00

28 lines
906 B
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.
---
title: "Bind Mount"
type: concept
tags: [docker, volume]
---
## 定义
Bind Mount绑定挂载是 Docker 的一种卷挂载方式,将宿主机上的文件或目录直接映射到容器内部,实现宿主机与容器间的文件共享。
## 工作原理
- 将宿主机目录 `/home/user/project` 挂载到容器内的 `/app`
- 宿主机上的文件修改可实时反映到容器内
- 容器内生成的文件可直接在宿主机访问
## 应用场景
- 开发环境:代码修改实时生效,无需重新构建镜像
- 日志收集:容器日志直接写入宿主机目录
- 配置文件:共享配置文件
## 优点
- 实现代码修改实时生效
- 无需重新构建镜像即可测试代码变更
- 便于调试和迭代开发
## 关联概念
- [[Docker]]:容器化平台
- [[docker-compose.yml]]Docker Compose 配置
- [[Volume]]Docker 持久化数据的另一种方式