💬 In this tutorial, we will get familiar with the basic usage of Apptainer (previously Singularity) containers.
sinteractiveor open a compute node shell in the Puhti web interface.
sinteractive --account <project> # replace <project> with your CSC project, e.g. project_2001234
wget https://a3s.fi/saren-2001659-pub/tutorial.sif ls -lh tutorial.sif
💬 There are three basic ways to run software in an Apptainer container:
apptainer exec tutorial.sif hello_world
grep "^NAME" /etc/os-release apptainer exec tutorial.sif grep "^NAME" /etc/os-release
💭 The tutorial container is based on Ubuntu 18.04. The host and the container use the same kernel, but the rest of the system can vary.
execin batch jobs
apptainer exec is the run method you will typically use in batch job scripts.
module load nano # The compute nodes do not have nano available by default nano test.sh
<project>with your actual CSC project, e.g.
#!/bin/bash #SBATCH --job-name=test # Name of the job visible in the queue. #SBATCH --account=<project> # Choose the billing project. Has to be defined! #SBATCH --partition=test # Job queues: test, interactive, small, large, longrun, hugemem, hugemem_longrun #SBATCH --time=00:01:00 # Maximum duration of the job. Max: depends of the partition. #SBATCH --mem=1G # How much RAM is reserved for job per node. #SBATCH --ntasks=1 # Number of tasks. Max: depends on partition. #SBATCH --cpus-per-task=1 # How many processors work on one task. Max: Number of CPUs per node. apptainer exec tutorial.sif hello_world
💡 For more information on batch jobs, see Docs CSC.
💬 When containers are created, a standard action called the
runscript is defined. Depending on the container, it may simply print out a message, or it may launch a program or service inside the container.
💭 If you are using a container created by someone else, you will need to check the documentation provided by the creator for details.
runscriptprints out a simple message:
apptainer run tutorial.sif
chmod u+x tutorial.sif ./tutorial.sif
apptainer inspect --runscript tutorial.sif
apptainer shell tutorial.sif
💬 This tutorial is meant as a brief introduction to get you started.
☝🏻 When searching online for instructions, pay attention that the instructions are for the same version of Apptainer as you are using. There has been some command syntax changes etc. between versions so older instructions may not work as copy/paste. Also note that Apptainer is formerly known as Singularity.
💡 For more detailed instructions, see the Apptainer documentation.