Accessing the files out of docker container

只愿长相守 提交于 2021-01-29 09:15:39

问题


I have created a docker container image, and working inside the container (setting up filesystem, creating code files, installing dependencies etc).

On my Ubuntu machine, I keep a huge file under a directory so called /dataset/my_data/.

When I work in the container, it is not straightforward to access the above directory. Is there any possibility to access it from inside the container image interactively? If yes, how?


回答1:


You can mount the directory as a volume:

docker ... --mount type=bind,source=/dataset/my_data,target=/some/directory

For example, to run a container called my-container with a bound volume:

docker run -it --mount \
  type=bind,source=/dataset/my_data,target=/target/directory \
  my-container

For all available possibilities, see Docker documentation.



来源:https://stackoverflow.com/questions/59386570/accessing-the-files-out-of-docker-container

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