How to use containers with singularity on biowulf

Author

Kelly Sovacool

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