在Docker容器中使用文件-Windows [英] use a file in docker containers - windows

查看:448
本文介绍了在Docker容器中使用文件-Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个分为两部分的问题.

This is a two part question.

1)在Windows中,可以共享除C驱动器以外的任何驱动器的文件夹吗?上网时,我发现默认情况下,只有C驱动器可以安装在Docker容器中. (C盘的用户文件夹)

1) In windows, can a folder form any drive apart from C drive be shared? While surfing the internet, I found that by default only C drive can be mounted in docker containers. (Users folder of C drive)

2)现在进入主要部分-我正在使用配置文件的骆驼项目中工作.在此配置文件中,我为 Servicemix 密钥库文件使用了两个参数.现在以前,密钥库位于路径-D:\sandboxes\apache-servicemix-7.0.0.M3\apache-servicemix-7.0.0.M3\etc\keystores.

2) Now coming to the main part - I am working on a camel project where I am using a config file. In this config file, I am using two parameters for Servicemix keystore files. Now previously the keystores are located at path - D:\sandboxes\apache-servicemix-7.0.0.M3\apache-servicemix-7.0.0.M3\etc\keystores.

我尝试给出此路径,但导致错误-

I tried giving this path and it resulted in error -

找不到文件

File not found

我将密钥库文件夹复制到C:\Users,然后给出了路径C:\Users\keystores,但错误仍然相同.

I copied the keystores folder to C:\Users and then gave the path C:\Users\keystores but the error remained the same.

现在,在运行docker run命令时,我已经在映射我的骆驼项目所在的卷-docker run -v //C/Users/camelproject:/app ...

Now while running the docker run command, I am already mapping the volume where my camel project is - docker run -v //C/Users/camelproject:/app ...

那么,是否可以使用-v选项从两个驱动器装载不同的文件夹?另外我该怎么做才能在项目中使用这些密钥库文件?

So, is it possible to mount different folders from two drives using -v option? Also what shall I do to use these keystore files in my project?

编辑1-

好的,所以我做了以下事情-

Okay, so I did the following things -

  • 将keystores文件夹复制到C驱动器中的我的骆驼项目中.现在的路径是-C:/Users/camelproject/src/main/resources/keystores
  • 在配置文件中将此路径用作keyStore=C:/Users/camelproject/src/main/resources/keystores/client.ks
  • 我正在camelcontext.xml中将此文件用作-<property name="keystore" value="${keyStore}" />
  • 我将文件夹安装为docker run -v //C/Users/camelproject:/app -v //C/Users/camelproject/src/main/resources:/app/config ...,然后在配置文件中将Windows和容器路径都指定为值,但对于两者,它给出了相同的错误.
  • Copied the keystores folder to my camel project in C drive. The path is now - C:/Users/camelproject/src/main/resources/keystores
  • Used this path in the config file as keyStore=C:/Users/camelproject/src/main/resources/keystores/client.ks
  • I am using this file in my camelcontext.xml as - <property name="keystore" value="${keyStore}" />
  • I mounted the folders as docker run -v //C/Users/camelproject:/app -v //C/Users/camelproject/src/main/resources:/app/config ... and then in the config file alternatively gave both, Windows and container path, as the value but for both it gave the same error.

因此基本上应该可以找到该文件,但错误即将来临.

So basically the file should be found but the error is coming.

推荐答案

那么,是否可以使用-v选项安装两个驱动器?

So, is it possible to mount two drives using -v option?

没有,这不可能,您需要对不同目录使用多个-v选项.

No this is not possible you need to use multiple -v option for different directories.

具有Windows卷挂载的Docker存在一些问题,它将不允许在路径中使用-"选项. (例如C:/camel-project)

Docker with windows volume mounting has some issues it will not allow " - " option in path. ( for example C:/camel-project )

始终不要使用/斜杠.

更多相关的讨论在这里完成. https://forums.docker. com/t/volume-mounts-in-windows-does-not-work/10693/7

More related discussion is been done here. https://forums.docker.com/t/volume-mounts-in-windows-does-not-work/10693/7

这篇关于在Docker容器中使用文件-Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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