Apptainer Containers on Longleaf
Introduction
Apptainer (formerly known as Singularity) containers are a lightweight, portable, and easy-to-use containerization technology. They are designed to be compatible with a wide range of Linux distributions and HPC schedulers. Apptainer containers are ideal for running applications on HPC clusters, as they allow users to package and distribute their applications in a consistent way and to isolate them from the underlying operating system.
Apptainer containers are similar to Docker containers in many ways. Both technologies provide a way to package and distribute applications in a portable and consistent way.
Apptainer Support for Docker Containers
In addition to supporting native Apptainer containers, Apptainer also supports Docker containers. This means that you can use Apptainer to run Docker containers on HPC clusters. To run a Docker container using Apptainer, you can use the apptainer run command followed by the Docker image name.
For example, the following command will run the nginx Docker container:
apptainer run docker://nginx
This will launch the nginx container and expose it on port 80. You can then access the nginx container by visiting the following URL:
http://localhost:80
The ability to run Docker containers using Apptainer is a powerful feature that allows users to leverage the large ecosystem of Docker containers on HPC clusters.
Building a Basic Container
The first step is to build a basic container. This can be done using the apptainer build command. The following command will create a container named my-container based on the ubuntu:18.04 image:
apptainer build my-container ubuntu:18.04
Launching a Bash Shell in a Container
Once you have built a container, you can launch a bash shell in it using the apptainer run command. The following command will launch a bash shell in the my-container container:
apptainer run my-container bash
Interacting with Containers
Once you are inside a container, you can interact with it just like you would any other Linux system. You can run commands, install software, and edit files.
To exit the container, simply type exit
.
Creating an Advanced Container Using a Definition File
Create a definition file.
A definition file is a YAML file that describes the contents and behavior of a container. The following is an example of a definition file for an advanced container:
name: my-advanced-container description: This container runs a web server and a database. baseImage: ubuntu:18.04 packages: - nginx - mysql-server commands: - service nginx start - service mysql start ports: - 80/tcp - 3306/tcp
Build the container.
Once you have created a definition file, you can build the container using the following command:
apptainer build my-advanced-container my-advanced-container.def
Run the container.
Once the container is built, you can run it using the following command:
apptainer run my-advanced-container
Access the container.
Once the container is running, you can access it using the following command:
apptainer exec my-advanced-container bash
This will launch a bash shell in the container. You can then use this shell to interact with the container.
Apptainer Versions
Multiple versions of Apptainer are available on Longleaf through the module system. This can be used if older versions are required for compatibility:
apptainer/1.1.7
apptainer/1.1.8
apptainer/1.1.9
apptainer/1.2.2-1
apptainer/1.3.0-1 (D)
Apptainer, formerly known as Singularity
In 2021, Sylabs, the company behind Singularity, announced that the project would be rebranded as Apptainer. This rebranding was done to reflect the project's evolution from a singular container runtime to a complete container platform.
The Apptainer platform includes a variety of tools and services for building, managing, and deploying containers on HPC systems. Apptainer is also a founding member of the Open Container Initiative (OCI), which is a collaborative effort to create a set of open standards for containers. The rebranding of Singularity to Apptainer reflects the project's commitment to providing a comprehensive and open container platform for HPC.
Example Container Solutions (coming soon):
- Custom Python
- QGIS
- Redis
- MySQL
Last Update 3/31/2025 5:33:11 AM