Skip to content
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

Document /tmp bind during %post #5514

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

Document /tmp bind during %post #5514

sapetnioc opened this issue Aug 19, 2020 · 9 comments
Labels
Documentation Something which can be solved via documentation

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.

Version of Singularity:

What version of Singularity are you using? Run:

$ singularity version

3.6.1+21-g0441c656a-dirty

Expected behavior

What did you expect to see when you do...?

Get an image created without error.

Actual behavior

What actually happend? Why was it incorrect?

...
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```

Steps to reproduce this behavior

How can others reproduce this issue/problem?

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

What OS/distro are you running

$ cat /etc/os-release


This is Ubuntu 18.04 but running in Windows 10 with WSL2.

NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.4 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

How did you install Singularity

Compiled from source copy/pasting lines from documentation (apt dependencies, go, go dependencies and build).

@jmstover
Copy link
Contributor

In the %post run the mount command. I think when it's running the %post section it's bind mounting in the host /tmp ... so the container /tmp is being hidden by the bind mount.

-J

@sapetnioc
Copy link
Author

This code is working on Singularity 3.5 (running on a true Linux, not under Windows + WSL2). This is why I posted this issue.

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 answer

@jmstover
Copy link
Contributor

@cclerget @dctrud ... is there a bind difference between versions during %post?

@cclerget
Copy link
Collaborator

cclerget commented Aug 21, 2020

@jmstover Yes build is now calling singularity exec instead of the build engine which has been removed in 3.6 and files are copied outside of the build namespace, that's why host /tmp and /var/tmp are mounted on top of /tmp and /var/tmp container directories during %post execution whereas the files were previously copied in the $IMG_BUILD_ROOTFS/tmp, not the host one.
While this can be considered as regression, I think 3.6 do the right thing with %files section because the intent of this section is to copy files from host filesystem (or from a previous stage) to container image without anything mounted in and the old behavior was a mistake. Previous versions supporting multistage build have this issue too :

bootstrap: docker
from: alpine
stage: one

%post
    echo "test" > /test

bootstrap: docker
from: alpine
stage: two

%files from one
    /test /tmp/test

%post
    ls -la /tmp/test

@sapetnioc To fix that, I would suggest to use %setup section instead :

Bootstrap: docker
From: ubuntu:18.04

%setup
    cp /home/me/test.sh /tmp/test.sh

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

@sapetnioc
Copy link
Author

Since I need a solution that works on various Singularity versions, I decided to use /opt instead of /tmp as suggested by @vsoch (in another equivalent issue that I posted in the wrong place). To my opinion, a warning should be added to the doc about the automatic bind mounts during %post.

@dtrudg dtrudg added the Documentation Something which can be solved via documentation label Sep 23, 2020
@dtrudg dtrudg changed the title Files copied with %file are not seen by %post under Windows + WSL2 + Ubuntu Document /tmp bind during %post Sep 23, 2020
@carterpeel
Copy link
Contributor

Hello,

This is a templated response that is being sent out to all open issues. We are working hard on 'rebuilding' the Singularity community, and a major task on the agenda is finding out what issues are still outstanding.

Please consider the following:

  1. Is this issue a duplicate, or has it been fixed/implemented since being added?
  2. Is the issue still relevant to the current state of Singularity's functionality?
  3. Would you like to continue discussing this issue or feature request?

Thanks,
Carter

@stale
Copy link

stale bot commented Jul 14, 2021

This issue has been automatically marked as stale because it has not had activity in over 60 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 14, 2021
@vsoch
Copy link
Collaborator

vsoch commented Jul 14, 2021

This issue seems like low hanging fruit - to document the binds during post. Please don't close stalebot.

@stale stale bot removed the stale label Jul 14, 2021
@kmuriki
Copy link
Collaborator

kmuriki commented Oct 17, 2022

Code repo has moved to Apptainer; this old issue is not relevant and being closed now. If there are any concerns please open a new issue under the new Apptainer repo. Thanks.

@kmuriki kmuriki closed this as completed Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Something which can be solved via documentation
Projects
None yet
Development

No branches or pull requests

7 participants