Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having Docker access External files

Tags:

docker

volume

I am interested in having Docker have access to external files, but I do not wish to include them as a volume. The files that I need access to will change over time, and this means I would need to re-mount repeatedly, unless I can mount a mere directory, and whatever is in that directory is also mounted.

I am just in need of allowing a software program pushed into a container, to run "over" my local system, where this software program has access to files on my local system.

Advice? Is there another way besides adding the files needing to be processed as a volume?

like image 348
sophie-germain Avatar asked Jun 04 '15 19:06

sophie-germain


2 Answers

I solved the same problem with below commands

docker run  --mount type=bind,source="$(pwd)"/data,target=/home/data -it <name_of_container>

Note "-it conainter_name" should be the last flags.

like image 113
Bharat Bhushan Avatar answered Sep 20 '22 05:09

Bharat Bhushan


It sounds like mounting a host directory in the container is what you're looking for. You won't have to restart the container to pick up changes to the mounted directory. Link to relevant docs.

like image 41
Kevan Ahlquist Avatar answered Sep 18 '22 05:09

Kevan Ahlquist