奇点配方的 %files 部分不直观地将文件复制到错误的绑定位置

%files section of Singularity recipe non-intuitively copies files to wrong bind location

我正在使用 CentOS 8 并使用 Singularity 3.6.2。我有一个奇点食谱文件:

BootStrap: yum
OSVersion: 8
MirrorURL: http://mirror.centos.org/centos-8/8/BaseOS/x86_64/os/
Include: yum

%files
/gpfs0/home1/group/user/path/to/some.rpm /tmp

%post
    ls /tmp
    echo "Hello from inside the container"

当我 运行 :

$ sudo singularity build test.simg tmp
INFO:    Starting build...
INFO:    Skipping GPG Key Import
INFO:    Adding owner write permission to build path: /tmp/rootfs-4db1e756-22a8-11eb-bb20-34800d2d90f0
INFO:    Copying /gpfs0/home1/group/user/path/to/some.rpm to /tmp/rootfs-4db1e756-22a8-11eb-bb20-34800d2d90f0/tmp
INFO:    Running post scriptlet
+ ls /tmp
qtsingleapp-RStudi-c679-6387e228-lockfile
rootfs-4db1e756-22a8-11eb-bb20-34800d2d90f0
rootfs-b10ad12c-229a-11eb-85a3-34800d2d90f0
+ echo 'Hello from inside the container'
Hello from inside the container
INFO:    Creating SIF file...

根据奇点documentation

In the default configuration, the system default bind points are $HOME , /sys:/sys , /proc:/proc, /tmp:/tmp,

问题:

  1. 为什么 %files 部分将我的 rpm 放在 /tmp/rootfs-4db1e756-22a8-11eb-bb20-34800d2d90f0/tmp 而不是 /tmp?这似乎与文档相矛盾。这也不同于使用 Singularity v2.5.1

    观察到的行为
  2. 此外,我将如何访问所述文件。路径的长 'hash-like' 部分似乎会根据构建而改变?

我没有将文档与 %files 部分实际放置文件的位置相协调的答案,但是对于如何访问复制的文件,我确实有答案。您需要在 %post 部分使用 ${SINGULARITY_CONTAINER}

例如

$ cat Singularity
BootStrap: yum
OSVersion: 8
MirrorURL: http://mirror.centos.org/centos-8/8/BaseOS/x86_64/os/
Include: yum

%files
# Will need to use environmental variables to copy the code to
/gpfs0/home/group/user/path/to/some.rpm /tmp

%post
    ls ${SINGULARITY_CONTAINER}/tmp
    echo "Hello from inside the container"

建筑收益时:

$ sudo singularity build tmp.simg tmp
INFO:    Starting build...
INFO:    Skipping GPG Key Import
INFO:    Adding owner write permission to build path: /tmp/rootfs-e2a3fbb4-242b-11eb-a267-34800d2d90f0
INFO:    Copying /gpfs0/home/group/user/path/to/some.rpm to /tmp/rootfs-e2a3fbb4-242b-11eb-a267-34800d2d90f0/tmp
INFO:    Running post scriptlet
+ ls /tmp/rootfs-e2a3fbb4-242b-11eb-a267-34800d2d90f0/tmp
some.rpm
+ echo 'Hello from inside the container'
Hello from inside the container
INFO:    Creating SIF file...