使用容器环境变量绑定奇异性的路径

发布于 2025-02-04 19:15:51 字数 598 浏览 3 评论 0原文

我有一个用 Scientific Filesystem )应用程序。 我以奇异性运行-App MyApp image.sif运行容器,因此,我有环境变量scif_appdata =/scif/scif/data/myapp在容器中设置。

我想使用此环境变量绑定路径。类似:

singularity run -B /my/path/on/host/:$SCIF_APPDATA/input/

不幸的是这不起作用。我没有设法将奇点用作安装路径,其“内部”值的环境变量。

我必须明确传递环境变量的值:

singularity run -B /my/path/on/host/:/scif/data/myapp/input

是否有人知道如何在绑定路径中使用容器环境变量?

I have a singularity container built with a scientific filesystem app.
I run the container with singularity run --app myapp image.sif and, accordingly, I have the environment variable SCIF_APPDATA=/scif/data/myapp set inside the container.

I'd like to bind a path using this environment variable. Something like:

singularity run -B /my/path/on/host/:$SCIF_APPDATA/input/

Unfortunately this does not work. I didn't manage to make singularity use as a mount path the environment variable with its "internal" value.

I have to explicitly pass the value of the environment variable:

singularity run -B /my/path/on/host/:/scif/data/myapp/input

Does anybody know how to use container environment variables in bind paths?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一个人练习一个人 2025-02-11 19:15:51

我认为不可能在绑定语句中直接使用来自容器内部的环境变量。但是,您可以分两个步骤执行此操作,首先调用singularity exec以获取变量的值,然后将其与sickularity Run

SCIF_APPDATA=$(singularity exec ascisoftApp.sif bash -c "echo \$SCIF_APPDATA")
singularity run -B /my/path/on/host/:$SCIF_APPDATA/input/ ...

不要忘记后斜手逃避回声命令中的$。

注意:不确定为什么,但是当我直接使用echo时,它对我不起作用,因此用bash -c包装。

I don't think it is possible to directly use environment variables from inside the container in the bind statement. However, you can do it in two steps, first a call to singularity exec to get the value of the variable, then use it with singularity run:

SCIF_APPDATA=$(singularity exec ascisoftApp.sif bash -c "echo \$SCIF_APPDATA")
singularity run -B /my/path/on/host/:$SCIF_APPDATA/input/ ...

Don't forget the backslash to escape the $ in the echo command.

Note: Not sure why but it doesn't work for me when I directly use echo, hence the wrapping with bash -c.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文