Singularity (opens new window) provides application containers for Linux that is also compatible with Docker.
# Install with Conda
- Conda (miniconda), see our Conda tutorial for more details.
- Conda channels: conda-forge, bioconda
Add the conda-forge channel
You will need the conda-forge channel to install Singularity. If you have not set channels yet make sure to add it:
conda config --add channels conda-forge
Install singularity in conda environment
Create environment and install Singularity:
conda create -n singularity -c conda-forge "singularity>=3.0.0"
Activate your singularity environment and try running Singularity:
conda activate singularity singularity --help
# Common practices and commands
All information is collected from official Singularity documentation (link above).
# Pull Docker image
You can use the pull (opens new window) and build (opens new window) commands to download pre-built images from an external resource like the Container Library (opens new window) or Docker Hub (opens new window).
#-- Example singularity pull library://library/default/alpine
#-- Example singularity build -B $TMPDIR lolcow.sif docker://godlovedc/lolcow
# Run Docker image
singularity pull library://alpine #-- The above command will save the alpine image from the Container Library as alpine_latest.sif.
To start an instance, you should follow below pattern:
singularity instance start -B $TMPDIR <image> <instance-name>
singularity instance start -B $TMPDIR alpine_latest.sif instance1
This command causes Singularity to create an isolated environment for the container services to live inside.
# Listing running containers
One can confirm that an instance is running by using the
instance list command like so:
singularity instance list INSTANCE NAME PID IMAGE instance1 12715 /home/ysub/alpine_latest.sif
# Stop running container
When you are finished with your instance you can clean it up with the
instance stop command as follows:
singularity instance stop instance1
# Where are the images stored ?
By default, Singularity will create a set of folders in your
$SINGULARITY_CACHEDIR directory for docker layers, Cloud library images, and metadata, respectively:
$SINGULARITY_CACHEDIR/cache/library $SINGULARITY_CACHEDIR/cache/oci $SINGULARITY_CACHEDIR/cache/oci-tmp
# Temporary file storage
By default, Singularity won't recognize lab tmp storage. You can apply lab tmp storage location
/mnt/scratch/tmp to a container using
-B $TMPDIR variable
#-- Example singularity shell -B $TMPDIR docker://ubuntu