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

First singularity-in-docker run fails with no loop device #3535

Open
dtrudg opened this issue Feb 19, 2025 · 1 comment
Open

First singularity-in-docker run fails with no loop device #3535

dtrudg opened this issue Feb 19, 2025 · 1 comment

Comments

@dtrudg
Copy link
Member

dtrudg commented Feb 19, 2025

The first run of Singularity inside Docker (as root in the container) with --privileged will fail with a loop device error:

$ docker run --privileged singularity:main --debug run docker://alpine
...
FATAL   [U=0,P=1]          Master()                      container creation failed: mount /proc/self/fd/3->/usr/local/var/singularity/mnt/session/rootfs error: while mounting image /proc/self/fd/3: failed to find loop device: could not attach image file to loop device: no loop devices available

The second run will complete without issue.

By examining /dev and --debug logs, it is apparent that during the first run, LOOP_CTL_ADD is called 256 times, creating /dev/loop0 -> /dev/loop255 on the host. The created loop devices are not visible in the container, however:

DEBUG   [U=0,P=136]        addLoopDev()                  LOOP_CTL_ADD for loop device 251
DEBUG   [U=0,P=136]        addLoopDev()                  Expected loop device 251 is not visible. Creating with mknod
DEBUG   [U=0,P=136]        attachLoop()                  couldn't open loop device 251: stat /dev/loop251: no such file or directory

This thread may be relevant:

https://forums.docker.com/t/can-only-create-one-loop-mount-inside-of-container/109498/6

@dtrudg
Copy link
Member Author

dtrudg commented Feb 19, 2025

A workaround is to bind in /dev to the Docker container with -v /dev:/dev so that the loop devices created are accessible. Alternatively they can be created on the host first. These approaches need documenting.

It would be nice to have a fall-back to using FUSE, if possible, though.

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

No branches or pull requests

1 participant