Singularity: failed to run a container directly or pull an image from Singularity or Docker hub

Category: 
Resolution: 
Resolved

You might encounter an error while run a container directly from a hub:

[pitzer-login01]$ apptainer run shub://vsoch/hello-world
Progress |===================================| 100.0%
FATAL: container creation failed: mount error: can't mount image /proc/self/fd/13: failed to find loop device: could not attach image file too loop device: No loop devices available

One solution is to remove the Singularity cached images from local cache directory $HOME/.apptainer/cache.

apptainer cache clean

Alternatively, you can change the Singularity cache directory to different location by setting the variable APPTAINER_CACHEDIR. For example, in a batch job:

#/bin/bash
#SBATCH --job-name="singularity_test"
#SBSTCH --ntasks=1

export APPTAINER_CACHEDIR=$TMPDIR
apptainer run shub://vsoch/hello-world