Reputation: 1310
I have a java app running on a docker container on mac osx. I want to access a file on a certain directory within the local file system using Paths.get('/Users/username/folder')
I am getting errors because docker is reading from its vm directory. How will I within a java app access the local file system while running the app in docker?
Upvotes: 4
Views: 12849
Reputation: 640
You can share the folder in the host machine with the container:
docker run -v your/host/folder:/your/container/folder ....
And then you can use Paths.get('/your/container/folder')
If you map the host folder in the same folder inside the container then you don't have to take care about it in the java code docker run -v your/folder:/your/folder ....
. You also have to keep in mind issues with permissions...
Upvotes: 6