Singularity ~ Apptainer
Singularity was created to run complex applications on HPC clusters in a simple, portable, and reproducible way. First developed at Lawrence Berkeley National Laboratory, it quickly became popular at other HPC sites, academic sites, and beyond. The user base continues to expand, with Singularity now used across industry and academia in many areas of work.
Tip
Singularity is the tool to run on HPCs, including ours! As you don't need root acces to run it (unlike docker).
Why Singularity?
Many container platforms are available, but Singularity is focused on:
- Verifiable reproducibility and security, using cryptographic signatures, an immutable container image format, and in-memory decryption.
- Integration over isolation by default. Easily make use of GPUs, high speed networks, parallel filesystems on a cluster or server by default.
- Mobility of compute. The single file SIF container format is easy to transport and share.
- A simple, effective security model. You are the same user inside a container as outside, and cannot gain additional privilege on the host system by default.
Singularity Installation
Singularity is available on most HPCs, but if you want to install it on your own machine, you can follow the instructions on the official website.
Info
Singularity is difficult to install on ARM chips (Apple silicon), haven\'t looked into it in detail.
In depth class
For a more in depth class for users with 0 experience, consider the course from SIB.
Cheatsheet
Downloading
Singularity can take several image formats (e.g. a docker
image), and convert them into it’s own .sif
format. Unlike docker
this image doesn’t live in a local image cache, but it’s stored as an actual file.
From docker
You can pull them from docker hub with singularity pull
. The syntax is:
From web/biocontainer
Given that singularity images are just files, one can download with wget
:
Running files
These .sif
files can be run as standalone executables:
Singularity is also different from Docker in the way it handles mounting. By default, Singularity binds your home directory and a number of paths in the root directory to the container. This results in behaviour that is almost like if you are working on the directory structure of the host.
Running with dir
It depends on the singularity settings whether most directories are mounted by default to the container. If your directory is not mounted, you can do that with the --bind
option of singularity exec
:
Running the command pwd
(full name of current working directory) will therefore result in a path on the host machine:
Running interactive
If you want to debug or inspect an image, it can be helpful to have a shell inside the container. You can do that with singularity shell
: