Data volumes provide several useful features for persistent or shared
Volume 于容器初始化之时即会创建,由 base image提供的卷中的数据会于此期间完成复制提供的卷中的数据会于此期间完成复制
## 数据量可以在容器之间共享和重用
Data volumes can be shared and reused among containers
## 直接更改数据量
Changes to a data volume are made directly
## 更新映像时将不包括对数据量的更改
Changes to a data volume will not be included when you update an image
## 即使删除容器本身,数据卷仍然存在
Data volumes persist even if the container itself is deleted
Volume的初衷是独立于容器的生命周期实现数据持久化,因此删除容器之时既不会删除卷,也不会对哪怕未被引用的卷做垃圾回收操作;
Docker有两种类型的卷,每种类型都在容器中存在一个挂载点,但其在宿主机上的位置有所不同;
## 绑定挂载卷
Bind mount volume
a volume that points to a user-specified location on the host file system
## 容器管理卷
Docker-managed volume
the Docker daemon creates managed volumes in a portion of the host'sfile system that's owned by Docker
There are two ways to share volumes between containers
多个容器的卷使用同一个主机目录,例如
# docker run – it --name c1 -v /docker/volumes/v1:/data busybox
# docker run – it --name c2 -v /docker/volumes/v1:/data busybox
复制使用其它容器的卷,为 docker run 命令使用 --volumes-from选项
# docker run -it --name bbox1 -v /docker/volumes/v1:/data busybox
# docker run -it --name bbox2 --volumes-from bbox1 busybox
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
2018-04-28 从任意长度的可迭代对象中分解元素
2018-04-28 将序列分解为单独的变量