Apptainer: Difference between revisions

From NU HPC Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Apptainer (former Singularity) is an open-source application for creating and running software containers, designed primarily for high-performance computing on shared Linux-based computing clusters systems.
Apptainer is the most widely used container system for HPC. It is a replacement (or next generation) for Singularity supported by the Linux Foundation.


Apptainer containers provide a custom user space and enable portable, reproducible, stable, and secure software environments on Linux systems. Apptainer container bundles a primary application and all of its dependencies into a single image file, which can also include data, scripts, and other files if desired. In addition, Apptainer containers have direct access to the Linux kernel on the host system, so there is no substantial performance penalty when using a container compared to using natively installed software on the host system.
Containers are a way to isolate your software and make it portable and reproducible. It is a valuable asset for reproducible science and, in addition, Its use is especially recommended when


With Apptainer, you can:
# Users rely on “old” libraries (e.g., HDF4);
# Users need to update their library constantly;
# It also makes the user more independent of the cluster admins.


* Install anything you want (based on any Linux operating system)
In this tutorial, we will show how to '''build your own containers''' on the cluster and '''submit jobs using containers'''.
* Ease installation issues by using pre-built container images
 
* Ensure the same software stack is used among a research group
== Instructions ==
* Use the same software stack across Linux systems (e.g., any HPC center or cloud computing service)
The steps to build a container always start with loading the apptainer module as follows
<code>module load apptainer</code>
For the next step, users have two options: 1) to just use a prebuilt image, or 2) to use a .def file (called recipe) that will contain the instructions to build the container. When using the latter option, we can build our container on top of another prebuilt image.
 
Building the container takes only one line of code, the structure (when building directly from a prebuilt image) is as follows
<code>apptainer build [OPTION] <name-for-the-container> <library>://<prebuilt-image></code>
In order to know all the available “options”, one can run <code>apptainer build --help</code>. For the <code><library></code> part, usually we rely on DockerHub (for more options see the apptainer documentation). In general, we are interested in building a container image that is a single .sif file that can be transferred between computers. However, there is an interesting option called --sandbox, which creates an expandable container image. Sandboxes will be useful when trying to build a custom image. However, this type of container has two side effects. First, these containers take up more space. Secondly, they are not reproducible.

Revision as of 06:53, 3 July 2024

Apptainer is the most widely used container system for HPC. It is a replacement (or next generation) for Singularity supported by the Linux Foundation.

Containers are a way to isolate your software and make it portable and reproducible. It is a valuable asset for reproducible science and, in addition, Its use is especially recommended when

  1. Users rely on “old” libraries (e.g., HDF4);
  2. Users need to update their library constantly;
  3. It also makes the user more independent of the cluster admins.

In this tutorial, we will show how to build your own containers on the cluster and submit jobs using containers.

Instructions

The steps to build a container always start with loading the apptainer module as follows

module load apptainer

For the next step, users have two options: 1) to just use a prebuilt image, or 2) to use a .def file (called recipe) that will contain the instructions to build the container. When using the latter option, we can build our container on top of another prebuilt image.

Building the container takes only one line of code, the structure (when building directly from a prebuilt image) is as follows

apptainer build [OPTION] <name-for-the-container> <library>://<prebuilt-image>

In order to know all the available “options”, one can run apptainer build --help. For the <library> part, usually we rely on DockerHub (for more options see the apptainer documentation). In general, we are interested in building a container image that is a single .sif file that can be transferred between computers. However, there is an interesting option called --sandbox, which creates an expandable container image. Sandboxes will be useful when trying to build a custom image. However, this type of container has two side effects. First, these containers take up more space. Secondly, they are not reproducible.