问题
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