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 管理节 ...
随机推荐
- Unity3D学习笔记——NGUI之UIInput
UIInput:这个组件可以用于创建输入框和编辑文本. 效果图如下: 一:使用步骤 1.首先创建一个背景,可以用Sprite也可以是Widget. 我这里使用的是空白的Widget 2.为其添加一个L ...
- 求伪逆矩阵c++代码(Eigen库)
非方阵的矩阵的逆矩阵 pseudoInverse 伪逆矩阵是逆矩阵的广义形式,广义逆矩阵 matlab中是pinv(A)-->inv(A). #include "stdafx.h&q ...
- Mac下使用安装MongoDB
1.安装方法1:Mac电脑上面安装很简单,直接下载需要的版本解压即可: 下载网址 https://www.mongodb.com/download-center?jmp=nav#community 方 ...
- Web API 2中的操作结果
how ASP.NET Web API converts the return value from a controller action into an HTTP response message ...
- Socket使用及简单实例
一.搭建服务器端 a).创建ServerSocket对象绑定监听端口. b).通过accept()方法监听客户端的请求. c).建立连接后,通过输入输出流读取客户端发送的请求信息. d).通过输出流向 ...
- CF 617E【莫队求区间异或和】
E. XOR and Favorite Number time limit per test 4 seconds memory limit per test 256 megabytes input s ...
- 【BZOJ3687】简单题 背包+bitset
[BZOJ3687]简单题 Description 小呆开始研究集合论了,他提出了关于一个数集四个问题:1.子集的异或和的算术和.2.子集的异或和的异或和.3.子集的算术和的算术和.4.子集的算术和的 ...
- angularjs 发送ajax请求的问题
在angularjs中使用 ajax 如果使用 jquery的 ajax发送请求会遇到结果返回了,但是页面的值却没有改变,如: $scope.queryNameMatch = function() { ...
- Java的默认构造函数调用
// 注意,这里不能是 public class OOO,否则编译无法通过,需把文件命名成 OOO.java class OOO { // 注意:如果不定义OOO(),那么Shapes(int i)编 ...
- 内置函数:sorted 用法
内置函数——sorted 对list.dict进行排序,Python提供了两个方法 对给定的List L进行排序,方法1: 用List的成员函数sort进行排序,在本地进行排序,不返回副本方法2: ...