Reputation: 53
I was trying to run a simple docker container with bind mount, so the application can read and modify data.json
file (from host machine). I placed data.json
in /home/usr/project
and ran the container with
docker container run -it -v /home/usr/project:/app container_name main.exe
project contains 3 files, rest of the 2 files were included in container build
. When I try to run the container, it gives the error about the other 2 files being not found. Placing those files in /home/usr/project
on local host solves the issue. Since, I want the container to only look for data.json
, is there any way I can do it without keeping other 2 files unnecessarily in the bind mount directory
Upvotes: 1
Views: 2176
Reputation: 98
You can map individual files in docker
docker run -it -v /home/usr/project/data.json:/app/data.json alpine cat /app/data.json
And you can even make them readonly inside the container to avoid unwanted modifications
docker run -it -v /home/usr/project/data.json:/app/data.json:ro alpine cat /app/data.json
Upvotes: 2