问题描述
我正在Windows的Docker环境中运行Docker Linux容器.我还使用Dockerfile为我的项目进行docker-compose.
I'm running a Docker Linux container in a Docker for Windows environment. I'm also using a Dockerfile to docker-compose up for my project.
我无法正确安装卷装载.特别是在我的 Kitematic 中,我看到文本'\ host_mnt'被添加到卷路径的开头.所以我的卷路径看起来像'\ host_mntC:\ Users \ blah \ blah \ blah'.路径正确,只是在开头添加了"\ host_mnt".
I'm having trouble getting my volume mounts to mount correctly. Specifically in my Kitematic I can see that the text '\host_mnt' is being added to the beginning of my volume path. So my volume path looks like '\host_mntC:\Users\blah\blah\blah'. The path is correct except that there is the '\host_mnt' being added to the beginning.
我怀疑我必须以某种方式将我的卷安装路径错误地放入了我的Dockerfile中.我尝试过使用相对路径,绝对路径,并同时使用卷的扩展符号和单行写入卷的方式.
My suspicion is that I have to somehow have my volume mount path put in incorrectly in my Dockerfile. I've tried using relative path, using absolute path and using both expanded notation for volumes and the one line way of writing volumes.
推荐答案
由于我使用的是Windows的Docker,因此在Docker图标上,如果右键单击并选择设置",然后选择共享驱动器",则需要确保该驱动器正在使用的是共享的.但是,还有一个示例,说明如何在其下方进行绑定安装.
Since I am using Docker for Windows, on the Docker icon if you right click and choose Settings, then Shared Drives, you want to make sure that the drive you are using is shared. But also there is an example of how you'd do a bind mount right beneath there.
在终端中,您可以运行示例:
In the terminal you can run the example:
docker run --rm -v c:/Users:/data alpine ls /data
"c:/Users:/data"是在Docker for Windows(自17.12.0-ce-win47版本)中编写用于绑定安装的路径文件的方式.
That 'c:/Users:/data' is the way of writing path files for bind mounts in Docker for Windows (as of version 17.12.0-ce-win47).
以同样的方式编写路径是您在docker-compose.yaml文件中编写路径的方式.如果打开Kitematic,该卷仍会显示'/host_mnt'文本,但这没关系,应该可以.
That same way of writing paths is how you'd write it in the docker-compose.yaml file. If you open up Kitematic the volume still shows up with '/host_mnt' text, but that is OK and it's supposed to.
这篇关于在具有批量安装的Windows上的Docker上运行Docker Linux容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!