use a file in docker containers - windows

▼魔方 西西 提交于 2019-12-24 07:47:30

问题


This is a two part question.

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) 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

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

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 ...

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?

Edit 1 -

Okay, so I did the following things -

  • 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.


回答1:


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

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

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

And always use / slash not .

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



来源:https://stackoverflow.com/questions/47881040/use-a-file-in-docker-containers-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!