使用docker选项--mount时,目标文件夹被视为不是绝对的,而使用-v时则没有问题 [英] When using docker option --mount the target folder is seen as not absolute, while there is no issue when using -v

查看:92
本文介绍了使用docker选项--mount时,目标文件夹被视为不是绝对的,而使用-v时则没有问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用docker并在使用--mount而不是-v装载docker卷时遇到问题.在我看来,弹出的错误是无效的,但可能我在这里缺少了一个小细节.

I am playing around with docker and ran into an issue when mounting docker volumes with --mount instead of -v. It appears to me that the error popping up is not valid, but probably I am missing a small detail here.

在--mount方案中,我要将容器中创建的映像绑定到的路径被视为不是绝对的.

The path to which I want bind the created image in the container is seen as not absolute in the --mount scenario.

我正在Windows 10计算机上运行Docker

I am running Docker on a windows 10 machine

我拉了jenkins/jenkins:lts图像,并想启动两个使用相同配置的容器.如前所述,我只是在玩docker,然后探索卷系统的工作方式.

I pulled the jenkins/jenkins:lts image and want to spin up 2 containers that use the same configuration. As said before I use this just to play around with docker, and am exploring how the volume system works.

我所做的是创建一个用于共享配置的docker卷.

What i did is create a docker volume that is used to share the configuarion.

docker volume create jenkins_cfg

然后我尝试运行2个容器.第一个容器始于:

Then I tried to run 2 containers. The first container started with:

docker run -d -p 8081:8080 --name jenkins2 -v jenkins_cfg:/var/jenkins_home jenkins/jenkins:lts

哪个工作正常.

第二个容器始于:

docker run -d -p 8085:8080 --name jenkin5 --mount source=jenkins_cfg,target=var/jenkins_home jenkins/jenkins:lts

这会导致错误"C:\ Program Files \ Docker \ Docker \ Resources \ bin \ docker.exe:来自守护程序的错误响应:类型"volume"的无效安装配置:无效的安装路径:'var/jenkins_home'的安装路径必须是绝对的.请参阅"C:\ Program Files \ Docker \ Docker \ Resources \ bin \ docker.exe运行--help"."

This results in the error "C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: invalid mount config for type "volume": invalid mount path: 'var/jenkins_home' mount path must be absolute. See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'."

/var/jenkins_home也无法正常工作.

Also /var/jenkins_home is not working properly.

虽然-v也要求提供相同的目标文件夹,但我认为该文件夹也可以在--mount的目标选项中使用.可能是我在这里忽略了某些东西...

While the -v also asks for the same target folder , i would assume that this folder would also work in the target option of --mount. Probably, I am overlooking something here ...

推荐答案

实际上,安装绑定就像将一部分物理磁盘卷安装到容器上一样.但是卷就像虚拟内存一样,您不能在没有容器的情况下独立访问它们,但是绑定装载可以独立访问

Actually mount binds are like mounting a part of physical disk volume to the containers. But volumes are like virtual memory you can't access them independently without containers but bind mounts can be accessed independently

您的装载绑定应该是主机中的绝对路径

Your mount binds should be an absolute path in your host

希望这有助于您的事业

这篇关于使用docker选项--mount时,目标文件夹被视为不是绝对的,而使用-v时则没有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆