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

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

问题描述

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

我只需要允许将软件程序推送到容器中,在"我的本地系统上运行,该软件程序可以访问我本地系统上的文件.

建议?除了将需要处理的文件作为卷添加之外,还有其他方式吗?

解决方案

我用下面的命令解决了同样的问题

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

<块引用>

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

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>

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

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

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