Apptainer (Singularity)
Apptainer (formally Singularity) allows for running containers on Viking and other HPCs. It can run containers built from Docker images, although a conversion is required first and we can now build the converted images on Viking directly. Please see apptainer.org for the complete documentation.
To load apptainer
on Viking run
module load Apptainer/latest
Build a container
It’s possible to build the containers on Viking directly, here we will give a very simple example where we build and then run a container from Docker Hub <https://hub.docker.com/>, more information can be found in the apptainer docs.
$ module load Apptainer/latest
$ apptainer build lolcow.sif docker://sylabsio/lolcow:latest
$ apptainer run lolcow.sif
_____________________________
< Mon Dec 25 09:00:00 GMT 2023 >
-----------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
Important
apptainer
images are run as read only. While this is great for reproducible results, it means that only files outside the image can be edited or created. Be aware that not all software suits this set up.
Example use step by step
Here is an example use of building and running a program through apptainer
step-by-step. This example is to allow us to use the DIA-NN program. I searched hub.docker.com and found an image with dia-nn
included, this is what we’ll use.
On Viking, from the command line:
$ module load Apptainer/latest
On the Viking command line we build the image. The docker://proteomicsunitcrg/dia-nn:latest
was made by putting docker://
in front of the container repository
and tag
as explained in the documentation.
$ apptainer build dia-nn.sif docker://proteomicsunitcrg/dia-nn:latest
This should build the image for you and save it as dia-nn.sif
in your current folder. If all goes well you can run it with the following:
--cleanenv
option$ apptainer shell --cleanenv dia-nn.sif
This should get you a shell
session within the container, the program diann
is located in the following directory, here I have it list its version:
$ /usr/diann/1.8/diann-1.8 --version
In this case I used the --cleanenv
option when running this container to stop it passing the current environment variables to the container.
Installing singularity on your local system
If you are running Linux and would like to install Singularity
locally on your system, Singularity
provide the free, open source Singularity Community Edition.
If you would like to attempt a local install of Singularity
, you can find details in the INSTALL.md file within the Singularity
repository that explains how to install the prerequisites (most notably Go
), build, and install the software.
If you do not have access to a Linux system where you can build and install Singularity
but you have administrative privileges on another system, you could look at installing a virtualisation tool such as VirtualBox on which you could run a Linux Virtual Machine (VM) image to install Singularity
.
If you have a Mac system, you can also try the beta release of Singularity Desktop for MacOS.