Having Docker access External files

后端 未结 3 546
南方客
南方客 2020-12-03 18:05

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 th

相关标签:
3条回答
  • 2020-12-03 18:47

    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.

    0 讨论(0)
  • 2020-12-03 18:47

    I wonder if the ADD command could help you accomplish your goal. For instance, given the Dockerfile line:

    ADD /Users/userX/myappfiles /appfiles
    

    and the command line:

    docker run myapp --input /myappfiles
    

    myapp would be able to access /Users/userX/myappfiles on the local filesystem to fetch its inputs.

    0 讨论(0)
  • 2020-12-03 18:54

    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.

    0 讨论(0)
提交回复
热议问题