Introduction to Singularity Containers on HPC

Background

Containers alleviate installation and portability challenges by packaging all the dependencies of an application within a self-sustainable image, a.k.a. a container. Linux container platforms such as Singularity and Docker allow you to install and use software within self-contained, portable, and reproducible environments. Linux containers allow users to:

  • Use software with complicated dependencies and environment requirements
  • Run an application container from the Sylabs Container Library or Docker Hub
  • Use a package manager (like apt or yum) to install software without changing anything on the host system
  • Run an application that was built for a different distribution of Linux than the host OS
  • Run the latest released software built for newer Linux OS versions than that present on HPC systems
  • Archive an analysis for long-term reproducibility and/or publication

What is a Container?

Put simply, a container consists of an entire runtime environment: an application, plus all its dependencies, libraries and other binaries, and configuration files needed to run it, bundled into one package. By containerizing the application platform and its dependencies, differences in OS distributions and underlying infrastructure are abstracted away.

Singularity Containers

Singularity is a tool for running software containers on HPC systems, similar to Docker. Singularity is the first containerization technology supported across DSRC HPC resources. In 2021, development of the container technology known as "Singularity" forked resulting in two similar products. Apptainer (https://apptainer.org/) is the new name of the open source branch homed at the Linux Foundation. The other branch is still known as "Singularity" and is developed by Sylabs (https://sylabs.io/). The Apptainer branch is the supported version on DSRC platforms but Singularity will continue to be supported until Apptainer becomes available on a platform. The basic capabilities of Apptainer and Singularity are still mostly the same and Singularity containers will often run unchanged on Apptainer.

Why Singularity?

Singularity is a container framework designed to run scientific applications on HPC-backed resources.

Singularity allows running Docker containers natively and is a replacement for Docker on HPC systems.

Singularity is built with HPC systems in mind, to solve many problems:

  • Security: a user in the container is the same user with the same privileges/permissions as the one running the container, so no privilege escalation is possible
  • Ease of deployment: no daemon running as root on each node, a container is simply an executable
  • Ability to mount local file systems or do bind mappings to access devices
  • Ability to run MPI and GPU HPC workflows with singularity containers

Accessing Singularity

Access Singularity by loading the "singularity" module: $ module load singularity $ which singularity /p/app/unsupported/singularity/4.0.0-git/bin/singularity $ singularity --version singularity-ce version 4.0.0-rc.1+89-gb5a90eb5c

Which Systems Support Singularity?

Singularity is installed on all production allocated HPC systems, restricted systems, and HPC Portal Appliances.

* Singularity containers are portable across any instruction set-compatible Linux system, like x86 Intel/AMD. You must build different Singularity containers for Power or Arm processor-based systems.

Which Version of Singularity is Available?

Singularity Version 3.8 is installed and supported across the production DSRC HPC systems where Apptainer is not yet installed.

Who Can Use Singularity Containers?

Any user may execute singularity containers on any supported systems. Container images may be placed and run from any system location: $HOME, $WORKDIR, $PROJECTS_HOME, etc.

Building Containers?

HPCMP HPC systems are able to build Singularity containers using the "—fakeroot" option to "singularity build." In addition, containers may be be built on other platforms and transferred to a DSRC machine:

  • The system named "Builder" at MHPCC is designed to be a container-building platform,
  • Your own system (laptop/workstation) where you have Apptainer installed,
  • A Portal Appliance

Training is Available on the HPC Training Website:

Training related to containers is available in the "Past Training" tab of the HPC Training site (https://centers.hpc.mil/users/HPCTraining.html#past. NOTE: You must have an "active" HPCMP account to access the HPC Training System.

Search for "Singularity" or "Container" to find courses on general container building and use as well as domain-specific applications of containers. Some courses to get started are:

Reference Containers and Examples

Reference containers for basic, MPI and GPU based workflows are provided on most systems for user convenience.

Reference containers, instructions, and run scripts are generally located at:

$PROJECTS_HOME/singularity/containers/examples

The README, in the examples directory, provides a complete description.

Public/community Information Sites