HPC Software – Virtualisation and Containers
Contents
Singularity/Apptainer
Singularity is a container platform. It allows you to create and run containers that package up pieces of software in a way that is portable and reproducible. You can build a container using Singularity on your laptop, and then run it on many of the largest HPC clusters in the world, local university or company clusters, a single server, in the cloud, or on a workstation down the hall. Your container is a single file, and you don’t have to worry about how to install all the software you need on each different operating system and system.
SingularityCE (Singularity Community Edition) and Apptainer are branches/children of the deprecated Singularity. SingularityCE is maintained by Sylabs while Apptainer is maintained by the Linux Foundation. By and large the two are interoperable with slightly different feature sets. The Ada Lovelace HPC system uses Apptainer, it is loaded by default as part of the OS when starting a session on the HPC.
Docker
Docker containers are a popular form of container. Unfortunately, due to its need for root access it’s not compatible on a lot of HPC systems. However, while the software isn’t compatible many of the file can be converted or imported into Singularity file that can be run using Apptainer.
Apptainer on the cluster
To use Apptainer on the cluster, it is recommended to first start an Open OnDemand. Then you simply run apptainer:
While the example uses apptainer as the command, singularity commands can also be used
[decostal@ada ~]$ apptainer --version
apptainer version 1.4.2-1.el9
when using singularity commands and the system will still apply them to apptainer;
[decostal@ada ~]$ singularity --version
apptainer version 1.4.2-1.el9
Downloading images to run in apptainer
Pull
There are many ways to use apptainer, the most common of which is using docker files and converting them to .sif file for use with singularity due to the reasons mentioned above. When downloading these docker files from the internet to the system there are a few options in commands and what they do;
Pull – Makes a copy of the docker image in .sif format.
apptainer pull docker://biobakery/workflows
This will make a .sif file called ‘workflows_latest.sif’ from the biobakery docker image. When using the ‘pull’ command it will always make an image of the latest version available. This is fine when starting out or if you can control the system it’s on but can cause issues for reproducibility.
Build
Build – Makes a copy of the docker image in .sif format, allows you to specify which version of the image and save it under a custom name. Here is the structure of the command and an example for biobakery;
apptainer build <desired_name_of_sif_file> docker://<address/of/image>:<version>
apptainer build biobakery_workflows.sif docker://biobakery/workflows:latest
After your apptainer file is created you can then access the shell with
apptainer shell biobakery_workflows.sif
or run commands directly to the shell with
apptainer exec biobakery_workflows.sif humann --help
Sandbox
You can also add the –sandbox flag when building a new apptainer image. when using the build command don’t add .sif to the file and use the sandbox flag as seen below. You may get some errors when building a sandbox file from docker. It shouldn’t affect the functionality.
apptainer build --sandbox biobakery_workflows/ docker://biobakery/workflows
You can then use the –writable flag with the shell command to enter the container shell and install software
apptainer shell --writable biobakery_workflows/
You can then use the app get command to install more programs inside the apptainer, once you’re done you can use the build command on the undefined file and rename it with the .sif extension
apptainer build biobakery_workflows.sif biobakery_workflows/
Definition File
You can also make a definition file and run it on the HPC. This makes the system download the base file and then run the install commands as part as a predefined process. This is great for reproducibility
Apptainer Documentation
The Apptainer User Guide has the latest documentation. You can also see the most up-to-date help on Apptainer from the command line:
[decostal@ada ~]$ apptainer --help
Linux container platform optimized for High Performance Computing (HPC) and
Enterprise Performance Computing (EPC)
Usage:
apptainer [global options...]
Description:
Apptainer containers provide an application virtualization layer enabling
mobility of compute via both application and environment portability. With
Apptainer one is capable of building a root file system that runs on any
other Linux system where Apptainer is installed.
Options:
--build-config use configuration needed for building containers
-c, --config string specify a configuration file (for root or
unprivileged installation only) (default
"/etc/apptainer/apptainer.conf")
-d, --debug print debugging information (highest verbosity)
-h, --help help for apptainer
--nocolor print without color output (default False)
-q, --quiet suppress normal output
-s, --silent only print errors
-v, --verbose print additional information
--version version for apptainer
Available Commands:
build Build an Apptainer image
cache Manage the local cache
capability Manage Linux capabilities for users and groups
checkpoint Manage container checkpoint state (experimental)
completion Generate the autocompletion script for the specified shell
config Manage various apptainer configuration (root user only)
delete Deletes requested image from the library
exec Run a command within a container
help Help about any command
inspect Show metadata for an image
instance Manage containers running as services
key Manage OpenPGP keys
keyserver Manage apptainer keyservers
oci Manage OCI containers
overlay Manage an EXT3 writable overlay image
plugin Manage Apptainer plugins
pull Pull an image from a URI
push Upload image to the provided URI
registry Manage authentication to OCI/Docker registries
remote Manage apptainer remote endpoints
run Run the user-defined default command within a container
run-help Show the user-defined help for an image
search Search a Container Library for images
shell Run a shell within a container
sif Manipulate Singularity Image Format (SIF) images
sign Add digital signature(s) to an image
test Run the user-defined tests within a container
verify Verify digital signature(s) within an image
version Show the version for Apptainer
Examples:
$ apptainer help []
$ apptainer help build
$ apptainer help instance start
For additional help or support, please visit https://apptainer.org/help/
If you encounter any issues using Apptainer, please reach out to ersearch@cqu.edu.au

