简体   繁体   English

Docker卷的安装点名称

[英]Mount point name for a docker volume

With the below command: 使用以下命令:

docker container run -dit --name testcontainer –mount source= ubervol, target=/vol alpine:latest

source mount point name is ubervol pointing to target /vol that resides within container as shown below: 安装点名称ubervol指向容器内的目标 /vol ,如下所示:

user@machine:~$ docker container exec -it b4fd sh
/ # pwd
/ 
/ # ls vol
vol

在此处输入图片说明

ubervol sits outside the container in /var/lib/docker/volumes/ubervol path of host machine(hosting docker daemon) ubervol坐在容器外侧/var/lib/docker/volumes/ubervol主机的路径(托管搬运工守护进程)


With the below Dockerfile: 使用以下Dockerfile:

# Create the folders and volume mount points
RUN mkdir -p /var/log/jenkins
RUN chown -R jenkins:jenkins /var/log/jenkins

RUN mkdir -p /var/jenkins_home
RUN chown -R jenkins:jenkins /var/jenkins_home

VOLUME ["/var/log/jenkins", "/var/jenkins_home"]

my understanding is, target is sitting within container with path /var/log/jenkins && /var/jenkins_home 我的理解是, 目标位于路径为/var/log/jenkins && /var/jenkins_home


What is the source mount point name? 源挂载点名称是什么? for each target( /var/log/jenkins && /var/jenkins_home ) 对于每一个目标( /var/log/jenkins && /var/jenkins_home

What is the path of this mount point name in host machine? 该安装点名称在主机中的路径是什么?

The location of the volume data on the host is an implementation detail that you shouldn't try to take advantage of. 卷数据在主机上的位置是一个实现细节,您不应尝试利用它。 On some environments, like the Docker Desktop for Mac application, the data will be hidden away inside a virtual machine you can't directly access. 在某些环境中,像泊坞窗Mac版桌面应用程序,数据将被藏起来在一个虚拟机,你不能直接访问。 While I've rarely encountered one there are also alternate volume drivers that would let you store the content somewhere else. 尽管我很少见过,但也有其他的卷驱动程序 ,可让您将内容存储在其他位置。

Every time you docker run a container based on an image that declares a VOLUME , if you don't mount something else with a -v option, Docker will create an anonymous volume and mount it there for you (in the same way as if you didn't specify a --mount source=... ). 你每次docker run基于声明的图像上的容器VOLUME ,如果不安装用别的东西-v选项,泊坞窗将创建一个匿名卷,而且将其加载为你(的方式,就好像你一样没有指定--mount source=... )。 If you start multiple containers from the same image, I believe each gets a new volume (with a different host path, if there is one). 如果你开始从同一图像的多个容器,相信每获得一个新的体积(用不同的主机路径,如果有的话)。 The Dockerfile cannot control the location of the volume on the host; Dockerfile无法控制卷在主机上的位置; the operator could mount a different named volume or a host directory instead. 操作员可以挂载其他命名卷或主机目录。

In practice there's almost no point to using VOLUME in a Dockerfile. 实际上,在Dockerfile中使用VOLUME几乎没有意义。 You can use docker run -v whether or not here's a VOLUME for the same directory. 无论是否为同一目录设置了VOLUME ,都可以使用docker run -v Its principal effect is to prevent future RUN commands from modifying that directory . 它的主要作用是防止将来的RUN命令修改该目录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM