Skip to content

Files copied with %file are not seen by %post under Windows + WSL2 + Ubuntu #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sapetnioc opened this issue Aug 19, 2020 · 4 comments
Closed

Comments

@sapetnioc
Copy link

I am trying to use Singularity (3.6.1+21-g0441c656a-dirty) under Windows with Ubuntu 18.04 and a fresh update providing WSL2 (a true Linux kernel in Windows 10). I was pleased to see that using images worked for me. (this was not the case with WSL1). But I got an error for image creation if I try to use files copied by %file in a %post section. I did the following :

touch /home/me/test.sh
sudo singularity build /tmp/test.sif /home/me/recipe

With the following recipe file :

Bootstrap: docker
From: ubuntu:18.04

%files
    /home/me/test.sh /tmp/test.sh

%post
    ls $SINGULARITY_CONTAINER/tmp
    chmod +x /tmp/*.sh

This produces the following output :

...
INFO:    Copying /home/me/test.sh to /tmp/rootfs-0530dbd9-e236-11ea-99e0-5e822267d58a/tmp/test.sh
INFO:    Running post scriptlet
+ ls /tmp/rootfs-0530dbd9-e236-11ea-99e0-5e822267d58a/tmp
test.sh
+ chmod +x /tmp/*.sh
chmod: cannot access '/tmp/*.sh': No such file or directory
FATAL:   While performing build: while running engine: exit status 1

test.sh is copied but is not accessible in /tmp from the %post script. It is located in /tmp/rootfs-<uuid>/tmp. This error is not present under a true Linux workstation.

@vsoch
Copy link
Member

vsoch commented Aug 19, 2020

hey @sapetnioc you would want to post issues to https://github.com/hpcng/singularity/issues - this is the web documentation for container tools (Singularity Hub, Registry, etc.). I can't transfer the issue because it's a different org, otherwise I'd do that for you. But one thing to try - since you are listing in $SINGULARITY_CONTAINER/tmp why not just chmod there? It does seem like a bug though, I'd report it.

@vsoch vsoch closed this as completed Aug 19, 2020
@sapetnioc
Copy link
Author

I will post the issue where it is supposed to go. Sorry.

Yes I can find a workaround but I noticed that in Linux, there is no SINGULARITY_CONTAINER variable but SINGULARITY_ROOTFS instead. But I realize that I do not have the same Singularity version on Linux (3.5.3). I should have checked that before saying it works on Linux.

@vsoch
Copy link
Member

vsoch commented Aug 19, 2020

If I remember correctly, in %post you shouldn't need to use SINGULARITY_CONTAINER or SINGULARITY_ROOTFS - it's only in setup. But one other detail - during build your container will bind your /tmp, so if you copy something to there isn't probably not going to persist. Maybe try somewhere else instead? This seems to work:

Bootstrap: docker
From: busybox

%files
    test.sh /opt/test.sh

%post
    ls /opt
    chmod +x /opt/*.sh
$ singularity shell container.sif 
Singularity> ls /opt/
test.sh

Most users won't use --containall to even if you had content in tmp, they probably wouldn't see it. It's safer not to use these automatically mounted folders.

@sapetnioc
Copy link
Author

I may have been lazy but I did not find information about /tmp in the doc. I only searched tmp and temp in the recipe file page. This may be a good idea to add a warning there.

Thank you for your answers, this was very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants