Apptainer (Singularity)¶
Introduction¶
Apptainer is a container technology, also known as lightweight virtualization (as the performance overhead compared to bare metal is close to zero), originally developed for HPC by Lawrence Berkeley National Laboratory, U.S.A.
The software website is https://apptainer.org.
It is a recent, rapidly developing product with a large and growing user community. As a result, its features evolve quickly.
Use of Apptainer at MUST¶
At MUST, Apptainer is available on all interactive machines and on all worker nodes.
Version availability¶
The LHC experiments use Apptainer, so MUST follows the versions required by the experiments.
You can get the current version with the following command:
Image repository¶
MUST provides an image repository (see Use and images management policy for more details), and images for the major versions of the following GNU/Linux distributions: CentOS, Ubuntu, Fedora and Debian.
These images are mainly provided as examples; you will usually need to customize them.
Building images¶
Images can now be built on the UI servers.
To build an image, you will need to write a definition file (a recipe).
For example, a definition file noble.def for Ubuntu Noble:
Bootstrap: docker
From: ubuntu:noble
%post
apt-get update
apt-get -y install gcc gfortran g++ bc bison build-essential ccache curl flex git gnupg gperf imagemagick liblz4-tool libncurses-dev lib32ncurses-dev lib32readline-dev lib32z1-dev libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev openjdk-8-jdk python3
apt-get clean
Then build your image:
Everything you need to write your definition file is here: https://apptainer.org/docs/user/main/definition_files.html
Invoking a container¶
You can run a script or a command within an image as follows:
Here we start a container and run the ls command in it; its output is shown on the screen. Once the command has run, the container is destroyed.
For more details, please refer to the official documentation Apptainer exec.
In the next examples, we start a container and open a shell in it.
The shell then runs in the OS environment of the chosen image.
$ apptainer shell /containers/apptainer/os/ubuntu/noble.sif
Apptainer> cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04 LTS"
(...)
WARNING messages may be displayed when the container starts. They usually come from image configuration inconsistencies or, more often, from errors while importing shell preferences into the container. However, this does not prevent the container from running.
With Apptainer, when starting the container, you need to declare all the external mount points you want to see inside it.
For instance, to access the /lapp_data or /uds_data storage, use the --bind option as follows:
Example:
$ ls /uds_data
autre-labo edytem irege lahc leca lmops Scratch
carrtel glearn isterre lama listic locie symme
$ apptainer shell --bind /uds_data /containers/apptainer/os/ubuntu/noble.sif
Apptainer> ls /uds_data
autre-labo edytem irege lahc leca lmops Scratch
carrtel glearn isterre lama listic locie symme
More than one filesystem may be mounted inside the container:
Warning
Contrary to the default Apptainer configuration, the user $HOME is not automatically mounted within the container on a Worker Node.
If you need to access it, use the --bind (or -B) option to mount it within the container.
Submitting a job to the computing cluster¶
The first method shown above (apptainer exec) can be used to submit a job to the computing cluster, in other words to run a script inside the container.
For instance, here is the script my_job.sh to run (the idea is to run cat /etc/os-release inside an Ubuntu container):
The HTCondor submit file my_job.submit:
Submit the job:
Another useful Apptainer command to run a script within a container is run; see the official documentation for details: apptainer run.
For more detailed information, please have a look at the official documentation, or open a ticket with user support (see contact).
Use and images management policy¶
MUST provides images for the major releases of the following GNU/Linux distributions: CentOS, Ubuntu, Fedora and Debian.
These images have been tested and are available from MUSTFS:
User support can help you solve any problem you may encounter when using one of these images.
You are allowed to create and import your own images. To minimize performance penalties when running large images, we recommend storing them on storage with good I/O performance.
To import your images into the repository, please contact user support (see contact).
MUST cannot guarantee that these unofficial images will run smoothly on MUST computing clusters. However, our experts will do their best to support you and help you solve your problems.
Docker images can also be used: Apptainer can run Docker images and convert them into Apptainer images if needed.