Singularity is a container technology. It allows the user to create a container (just like Docker ones) where all the needed software can be autonomously managed.
By software we mean that almost everithing, from the operative system up, can be customized and run regardless the hosting OS.
The terms Apptainer and Singularity can be considered synonyms.
The original project was called Singularity but it became Apptainer once it was moved into the Linux Foundation. SingularityCE also exists and it's a fork of Singularity, owned by a private company.
The choice of one of these three container technology is virtually irrelevant as they have an almost complete compatibility.
Some Linux distributions, like Ubuntu 22.04, may contain SingularityCE while others have Apptainer or both.
Important!
This is not a Singularity tutorial. Please read the Singularity user guide first if you're starting from scratch.
You tipically build the singularity file on your PC. The Singularity image can then be transferred to your homedir or to a shared folder and be run there.
On your own computer starting from a Singularity definition file, let's say singularity.def, you can build a container, let's say singularity.sif:
sudo singularity build --tmpdir /locale singularity.sif singularity.def
Or you can build a writable container, using the folder here called "sandboxed" as a support:
sudo singularity build --sandbox sandboxed singularity.sif
singularity shell --writable sandboxed/
In the end, this will be made "immutable" with the following command:
sudo singularity build singularity.sif sandboxed/
As an alternative, you can start from an already built image downloaded from the singularity hub repository:
sudo singularity build singularity.sif shub://vsoch/hello-world
or importing directly a Docker image:
sudo singularity build singularity.sif docker://ubuntu
You can even create a singularity image in your personal space when in an interactive session:
sinteractive
apptainer build imageName.sif docker://containerPath
You will see some information about the process:
INFO: Starting build...
INFO: Creating SIF file...
and after some time:
INFO: Build complete: imageName.sif
You can run or modify your container on your local PC until satisfied. To test run your image you can use
singularity shell singularity.sif
or, to access the container interactively
singularity exec singularity.sif
Once copied on the cluster platform the Singularity image can be executed with a slurm job file like the one described below.
The user home path is automatically mapped inside the container so you can immediately access your files and directories.
Another folder which is available when launching a container is the execution directory, that is the directory we are in where we launch the environment.
If you want to map another directory, let's say /my_dir, you need to add the --bind /my_dir
option:
singularity shell --bind /my_dir
.
The alternative shorter form is -B /my_dir
.
In many cases building a customized Singularity image is the only solution applicable. We have some prebuilt containers though and if they fit your needs they're the easiest way to go.
Our images are stored in the following location:
In May 2024, we provide this kind of containers: