wiki:cypress/SingularityDockerhub

Version 10 (modified by cbaribault, 8 hours ago) ( diff )

Added explanation for r-base

Build Singularity Containers from Dockerhub

Docker is a container virtualization environment that can establish development or runtime environments without modifying the environment of the base operating system. It runs on Mac and Windows.

Use CentOS 7

To use Singularity on Cypress, you have to use one of the computing nodes running version CentOS 7 of the operating system.

For Workshop

idev --partition=workshop7

Non Workshop

idev --partition=centos7

Example 1: Building a container for Ubuntu

Load the module,

module load singularity/3.9.0

Build from Docker Hub, for example ubuntu 14.04

singularity pull docker://ubuntu:14.04

Singularity uses /tmp as a default temporary directory for building images. /tmp is just 2Gbyte so you might encounter errors because of no space on disk. In such case, you should set SINGULARITY_TMPDIR as, for example,

export SINGULARITY_TMPDIR=$TMPDIR

For convenience, we've already done the above for you as well as providing access to LUSTRE, etc., when you perform the following.

source /lustre/project/singularity_images/setup_cypress.sh

Here's what the file setup_cypress contains.

cat /lustre/project/singularity_images/setup_cypress.sh
# Set $TMPDIR in containar to /tmp, keeping $TMPDIR in host (/local/tmp/...)
export SINGULARITYENV_TMPDIR=/tmp
# Mount the lustre directory to home, $TMPDIR to /tmp
export SINGULARITY_BINDPATH=/cm:/cm,/share:/share,/lustre:/lustre,/home:/home,$TMPDIR:/tmp

By default, the cache is stored in ~/.singularity; this location can be customized using the environmental variable SINGULARITY_CACHEDIR. A subcommand, singularity cache, can be used to manage the cache.

Example 2: Building a container including the latest version of R

The following command creates ‘r-base_latest.sif’, which is the Singularity Image. You can rename/transfer it as you like.

singularity pull docker://r-base:latest  # creating .sif file takes ~6 minutes

Next we can enter the container shell and interactively query the R environment.

singularity shell -s /bin/bash r-base_latest.sif
Singularity> head -1 /etc/os-release
PRETTY_NAME="Debian GNU/Linux 13 (trixie)"
Singularity> Rscript -e 'R.version.string'
[1] "R version 4.5.1 (2025-06-13)"
Singularity>exit

Alternatively, we can execute just a single command inside the container to query the R environment.

singularity exec r-base_latest.sif Rscript -e 'R.version.string'
[1] "R version 4.5.1 (2025-06-13)"

Example 3: FastDTLmapper

This tool depends on many python packages and requires both python2 and python3. Fortunately, the developer provides Docker Images so we can use it to generate a Singularity image.

On Centos7 computing node, (need 'idev'),

module load singularity/3.9.0
singularity pull docker://ghcr.io/moshi4/fastdtlmapper:latest

This command creates ‘fastdtlmapper_latest.sif’, which is the Singularity Image. You can rename/transfer it as you like.

To run it to show ‘help’,

singularity exec fastdtlmapper_latest.sif FastDTLmapper -h

To run it with the minimum test dataset, Assuming the example dataset is extracted under /lustre/project/group/user/fastdtlmapper, where 'group' is the group name and 'user' is the user name,

export SINGULARITYENV_TMPDIR=/tmp
export SINGULARITY_BINDPATH=/lustre/project/group/user:/home/user,$TMPDIR:/tmp
singularity exec fastdtlmapper_latest.sif FastDTLmapper -i fastdtlmapper/example/minimum_dataset/fasta/ -t fastdtlmapper/example/minimum_dataset/species_tree.nwk -o fastdtlmapper/output_minimum

For Slurm batch jobs,

#!/bin/bash
#SBATCH --job-name=fastDLmapper # Job Name
#SBATCH --partition=centos7    # Partition
#SBATCH --qos=normal           # Quality of Service
#SBATCH --time=0-24:00:00      # Wall clock time limit in Days-HH:MM:SS
#SBATCH --nodes=1              # Node count required for the job
#SBATCH --ntasks-per-node=1    # Number of tasks to be launched per Node
#SBATCH --cpus-per-task=20     # Number of threads per task (OMP threads)
#SBATCH --output=try_fastDLmapper.out       ### File in which to store job output
#SBATCH --error=try_fastDLmapper.err        ### File in which to store job error messages
 
# Load Singularity module
module load singularity/3.9.0
 
# Set $TMPDIR in containar to /tmp, keeping $TMPDIR in host (/local/tmp/...)
export SINGULARITYENV_TMPDIR=/tmp
 
# Mount the lustre directory to home, $TMPDIR to /tmp
export SINGULARITY_BINDPATH=/lustre/project/group/user:/home/user,$TMPDIR:/tmp
 
# Run container
singularity exec fastdtlmapper_latest.sif FastDTLmapper -i fastdtlmapper/example/minimum_dataset/fasta/ -t fastdtlmapper/example/minimum_dataset/species_tree.nwk -o fastdtlmapper/output_minimum
Note: See TracWiki for help on using the wiki.