允许Docker访问外部文件 [英] Having Docker access External files

查看:987
本文介绍了允许Docker访问外部文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对让Docker能够访问外部文件感兴趣,但是我不希望将它们作为卷包含在内。我需要访问的文件会随着时间的推移而变化,这意味着我将需要反复重新挂载,除非我可以挂载一个目录,并且该目录中的任何内容也都挂载。

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?

推荐答案

我使用以下命令解决了相同的问题

I solved the same problem with below commands

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




注意 -it conainter_name应该是最后一个标志。

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

这篇关于允许Docker访问外部文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆