Docker 数据管理-bind mount
Use bind mounts
Bind mounts have been around since the early days of Docker. Bind mounts have limited functionality compared to volumes. When you use a bind mount, a file or directory on the host machine is mounted into a container. The file or directory is referenced by its full or relative path on the host machine. By contrast, when you use a volume, a new directory is created within Docker’s storage directory on the host machine, and Docker manages that directory’s contents.
Start a container with a bind mount
Consider a case where you have a directory source and that when you build the source code, the artifacts are saved into another directory source/target/. You want the artifacts to be available to the container at /app/, and you want the container to get access to a new build each time you build the source on your development host. Use the following command to bind-mount the target/ directory into your container at /app/. Run the command from within the source directory. The $(pwd) sub-command expands to the current working directory on Linux or macOS hosts.
The --mount and -v examples below produce the same result. You can’t run them both unless you remove the devtest container after running the first one.
--mount 语法格式:
$ docker run -d \
-it \
--name devtest \
--mount type=bind,source="$(pwd)"/target,target=/app \
nginx:latest
-v 语法格式:
$ docker run -d \
-it \
--name devtest \
-v "$(pwd)"/target:/app \
nginx:latest
Mounting into a non-empty directory on the container
If you bind-mount into a non-empty directory on the container, the directory’s existing contents are obscured(覆盖) by the bind mount. This can be beneficial, such as when you want to test a new version of your application without building a new image. However, it can also be surprising and this behavior differs from that of docker volumes.
Docker 数据管理-bind mount的更多相关文章
- [转帖]Docker的数据管理(volume/bind mount/tmpfs)
Docker(十五)-Docker的数据管理(volume/bind mount/tmpfs) https://www.cnblogs.com/zhuochong/p/10069719.html do ...
- Docker(十五)-Docker的数据管理(volume/bind mount/tmpfs)
Docker提供了三种不同的方式用于将宿主的数据挂载到容器中:volumes,bind mounts,tmpfs volumes.当你不知道该选择哪种方式时,记住,volumes总是正确的选择. vo ...
- Docker的数据管理(volume/bind mount/tmpfs)
Docker提供了三种不同的方式用于将宿主的数据挂载到容器中:volumes,bind mounts,tmpfs volumes.当你不知道该选择哪种方式时,记住,volumes总是正确的选择. vo ...
- Data Volume 之 bind mount - 每天5分钟玩转 Docker 容器技术(39)
storage driver 和 data volume 是容器存放数据的两种方式,上一节我们学习了 storage driver,本节开始讨论 Data Volume. Data Volume 本质 ...
- Docker 数据管理-三种数据mount方式
可以在Container可写层存储数据,但是有三个缺点: 当Container销毁时,数据不能持久保存. Container的可写层和Container所在的主机紧耦合,不容易将数据移动到其他地方. ...
- docker的volume和bind mount究竟有什么区别?
不知道你在使用docker的时候,有没有注意到volume mount和bind mount的使用? 进一步说,他们之间的区别到底是什么? 接下来的内容,我们就为你揭开他们的神秘面纱. 相同之处 首先 ...
- <Docker学习>5. docker数据管理
当我们创建了一个tomcat容器,如何简单部署一个web应用?如何将war包放入到容器中?也就是说怎么样把文件从宿主机中 "放入" 到容器中? docker cp命令可以将宿主机本 ...
- 039、Data Volume 之 bind mount (2019-02-28 周四)
参考https://www.cnblogs.com/CloudMan6/p/7142150.html Date Volume 本质上是Dokcer host文件系统中的目录或者文件,能够直接被 ...
- Docker Swarm bind 数据持久化
Docker Swarm bind 数据持久化 bind:主要将工作节点宿主级文件或目录,同步挂载到容器中. 环境: 系统:Centos 7.4 x64 应用版本:Docker 18.09.0 管理节 ...
随机推荐
- SharePoint2013导入Excel到列表
using Microsoft.SharePoint; using System; using System.Collections.Generic; using System.ComponentMo ...
- 如何获取继承中泛型T的类型
@SuppressWarnings("unchecked") public void testT() { clazz = (Class<T>)( (Parameteri ...
- Ubuntu 下Apache安装和配置2
在Ubuntu上安装Apache,有两种方式:1 使用开发包的打包服务,例如使用apt-get命令:2 从源码构建Apache.本文章将详细描述这两种不同的安装方式. 方法一:使用开发包的打包服务—— ...
- 二、Android应用的界面编程(二)布局管理器
一.线性布局所有布局都可以作为容器类使用,因此可以调用多个重载的addView()向布局管理器中添加组件.实际上,我们完全可以用一个布局管理器嵌套到其他布局管理器中---因为布局管理器也继承了View ...
- python学习【第四篇】python函数 (一)
一.函数的介绍 函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段. 函数能提高应用的模块性,和代码的重复利用率.你已经知道Python提供了许多内建函数,比如print().但你也可以 ...
- 【BZOJ1053】[HAOI2007]反素数ant 暴力
[BZOJ1053][HAOI2007]反素数ant Description 对于任何正整数x,其约数的个数记作g(x).例如g(1)=1.g(6)=4.如果某个正整数x满足:g(x)>g(i) ...
- 【BZOJ2186】[Sdoi2008]沙拉公主的困惑 线性筛素数
[BZOJ2186][Sdoi2008]沙拉公主的困惑 Description 大富翁国因为通货膨胀,以及假钞泛滥,政府决定推出一项新的政策:现有钞票编号范围为1到N的阶乘,但是,政府只发行编号与M! ...
- JS实现全选,全不选
<script type="text/javascript"> function selectItem() { document.getElementById(&quo ...
- Windows下批处理文件(.bat)的使用
cmd文件和bat文件的区别:在本质上两者没有区别,都是简单的文本编码方式,都可以用记事本创建.编辑和查看.两者所用的命令行代码也是共用的,只是cmd文件中允许使用的命令要比bat文件多.cmd文件只 ...
- MySQL复制(三):常见的复制任务
复制案例:包括横向扩展.热备 报表 企业需要挖掘有价值的报表信息,使用SLAVE,可以避免干扰到master的复制. 通过binlog获取某个时间范围的所有事件 $ mysqlbinlog --for ...