How to use containers with singularity on biowulf
Log in to biowulf and start an interactive session.
sinteractiveLoad the singularity module
module load singularityPull the container image from dockerhub:
singularity pull docker://kellysovacool/minimal:v2Singularity will convert the docker image to a SIF file and write it in your current directory.
file minimal_v2.sifminimal_v2.sif: a /usr/bin/env run-singularity script executable (binary data)
Run the container in an interactive bash shell:
singularity shell minimal_v2.sif bashAlternatively, you can pull the container and run it interactively in one command like this:
singularity shell docker://kellysovacool/minimal:v1 bashRun any commands you wish to while inside the container.
You can exit the container by typing exit and pressing enter.
Cache directory
Singularity caches images in a directory set by the SINGULARITY_CACHEDIR environment variable. By default, this is set to $HOME/.singularity. However, there is limited space in user’s home directories. Instead, we recommend setting it to a location with more disk space, such as /data/$USER/.singularity.
You can set this custom cache directory location by pasting the following line in your ~/.bashrc or ~/.zshrc:
export SINGULARITY_CACHEDIR=/data/$USER/.singularityThis will take effect if you log out and log back in, or source your rc file. You can check the cache directory variable like so:
echo $SINGULARITY_CACHEDIR/data/$USER/.singularity
(Your own username will appear instead of $USER.)
Package versions
R
You can find out the versions of R packages installed in a container like so:
singularity exec docker://nciccbr/carlisle_r:v2 R -e "readr::write_tsv(tibble::as_tibble(installed.packages()), 'r-packages.tsv')"This command runs R code in the container to write the installed packages to a TSV file called r-packages.tsv.
Python
Run this command to find out the versions of Python packages installed in a container:
singularity exec docker://nciccbr/ccbr_ubuntu_22.04:v4 pip list > pip_list.txtThe packages & versions are written to pip_list.txt.