Apptainer: Difference between revisions

From RCSWiki
Jump to navigation Jump to search
Pemartin (talk | contribs)
Merge Singularity to Apptainer page content
 
Line 1: Line 1:
= General =
= General =
Apptainer lets users run applications and jobs inside a Linux container. This allows for applications that were built to run on a different distribution of Linux or have specific software dependencies that are not compatible with our cluster systems to run. Applications from the [https://singularity-hub.org/ Singularity Hub] or [https://hub.docker.com Docker Hub] can run without needing to install anything.
== Usage ==
Apptainer is available on ARC and is installed on all nodes. The most current version of Singularity will be installed at every major upgrade. Currently, Singularity 3.8.0 is installed on all nodes. Older versions can be used from modules (Eg. module load singularity/2.4.1).
Apptainer can be used interactively. If you wish to enter a specific environment provided by a container, such as Ubuntu:
# apptainer shell docker://ubuntu
Adding Packages to a Docker Image
Build a "Sandbox" of the dockerhub image -- we'll use the docker centos:7.6.1810 image as an example:
# apptainer build --sandbox /tmp/centos/ docker://centos:7.6.1810
Modify the image -- add the emacs editor into the image:
Note the "-f" which means to use fakeroot which gives root privilege inside the conainer (so you can use yum install)
# apptainer run -f -w /tmp/centos/ yum -y install emacs
Package up the sandbox into a singularity 1 file image:
# apptainer build -f centoswithemacs.simg /tmp/centos/
Now you can use the container image in a job (replacing <your computation> with the program inside the container that you want to run):
# apptainer run centoswithemacs.simg <your computation>
Converting a Docker image into a Apptainer image
You can convert a Docker image that has already been pulled on your system into a Singularity image file with the following command:
# apptainer build /tmp/output.sif docker-daemon://input:latest


== Accessing data outside the container ==
== Accessing data outside the container ==
Line 12: Line 47:
To bind the <code>/work</code>, and <code>/bulk</code>, and <code>/scratch</code> file systems,  
To bind the <code>/work</code>, and <code>/bulk</code>, and <code>/scratch</code> file systems,  
you have to add the <code>-B</code> option to your '''apptainer command line'''. Like this:
you have to add the <code>-B</code> option to your '''apptainer command line'''. Like this:
  apptainer -B /work,/bulk,/scratch ....
  # apptainer -B /work,/bulk,/scratch ....


This change ensures that these file systems will be available for programs running from inside the container.
This change ensures that these file systems will be available for programs running from inside the container.

Latest revision as of 17:12, 24 August 2026

General

Apptainer lets users run applications and jobs inside a Linux container. This allows for applications that were built to run on a different distribution of Linux or have specific software dependencies that are not compatible with our cluster systems to run. Applications from the Singularity Hub or Docker Hub can run without needing to install anything.

Usage

Apptainer is available on ARC and is installed on all nodes. The most current version of Singularity will be installed at every major upgrade. Currently, Singularity 3.8.0 is installed on all nodes. Older versions can be used from modules (Eg. module load singularity/2.4.1).

Apptainer can be used interactively. If you wish to enter a specific environment provided by a container, such as Ubuntu:

# apptainer shell docker://ubuntu


Adding Packages to a Docker Image

Build a "Sandbox" of the dockerhub image -- we'll use the docker centos:7.6.1810 image as an example:

# apptainer build --sandbox /tmp/centos/ docker://centos:7.6.1810

Modify the image -- add the emacs editor into the image: Note the "-f" which means to use fakeroot which gives root privilege inside the conainer (so you can use yum install)

# apptainer run -f -w /tmp/centos/ yum -y install emacs

Package up the sandbox into a singularity 1 file image:

# apptainer build -f centoswithemacs.simg /tmp/centos/


Now you can use the container image in a job (replacing <your computation> with the program inside the container that you want to run):

# apptainer run centoswithemacs.simg <your computation>

Converting a Docker image into a Apptainer image

You can convert a Docker image that has already been pulled on your system into a Singularity image file with the following command:

# apptainer build /tmp/output.sif docker-daemon://input:latest


Accessing data outside the container

Containers are separated from the storage that is on the system. This is why they are containers. All the data that they need to run are inside the container.

If one needs to get access to any data outside the container, one has to bind the external storage to the container. By default, only few locations are bound to containers, including the home directory of the user who runs the container.

To bind the /work, and /bulk, and /scratch file systems, you have to add the -B option to your apptainer command line. Like this:

# apptainer -B /work,/bulk,/scratch ....

This change ensures that these file systems will be available for programs running from inside the container.

Links

ARC Software pages