How to use containers with singularity on biowulf
Log in to biowulf and start an interactive session.
sinteractive
Load the singularity module
module load singularity
Pull the container image from dockerhub:
singularity pull docker://kellysovacool/minimal:v2
Singularity will convert the docker image to a SIF file and write it in your current directory.
file minimal_v2.sif
minimal_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 bash
Alternatively, you can pull the container and run it interactively in one command like this:
singularity shell docker://kellysovacool/minimal:v1 bash
Run 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/.singularity
This 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.txt
The packages & versions are written to pip_list.txt
.