Containers on NRIS HPC systems


Currently, Singularity is the only supported container solution on our HPC systems (Saga, Fram, Betzy). However, since Singularity can build containers from Docker images, it is also possible to run Docker containers through Singularity.

What is a container image

Container image is a package with all cargo needed for a software to work. This includes the operating system, system packages, libraries and applications as a single unit. It only uses the host operating systems kernel.

What is not covered in this document

We are showing how to use existing container images on our systems as regular users. Operations that require root access, like building or making changes to an images not discussed.

When to use containers on NRIS HPC systems


Please let us know if you find more reasons for using containers

  • If you have a software stack or a pipeline already setup somewhere else and you want to bring it as it is to one of the HPC systems

    • Containers give the users the flexibility to bring a full software stack to the cluster which has already been set up, which can make software installations and dependencies more reproducible and more portable across clusters.

  • The software you want to use is only available as a container image

  • You need to use system level installations, e.g. the procedure involved apt-get install SOMETHING or similar (yum, rpm, etc).

  • You have a old software that needs some older dependencies.

  • You need a specific version of a software to run another software, e.g. CUDA.

When not to use containers on NRIS HPC systems

  • If the software you are planing to to use already installed as a module(s), then better to use that module or collection of modules

  • Windows containers. On NRIS HPC systems only containers that uses UNIX kernel would work

  • If you do not know what the container is exactly for. i.e. found a command on the internet and just want to try it out

How to access singularity on NRIS HPC systems

Singularity is already installed globally on all our systems, and should be immediately available on your command line (no module load necessary):

[SAGA]$ singularity --version
singularity version 3.6.4-1.el7

How to find container images

How to get container images

Singularity images can be fetched from the web using the singularity pull command, which will download a SIF (Singularity Image Format) file to your current directory. Notice that with Singularity, an image is just a simple binary file, and there’s nothing special about the directory in which you run the singularity pull command. This means that you can move your image around as you please, and even scp it to a different machine and execute it there (as long as you have Singularity installed, of course).

There are a number of different online repositories for hosting images, some of the more common ones are listed below. Notice how you can pull Docker images directly from Docker-Hub using Singularity.

#Fetching from a [Singularity]( registry:
$ singularity pull --name hello-world.sif shub://vsoch/hello-world

#Fetching from a [Sylabs]( registry:
$ singularity pull --name alpine.sif library://alpine:latest

#Fetching from a [Docker-Hub]( registry:
$ singularity pull --name alpine.sif docker://alpine:latest

#Fetching from a [Quay]( registry:
$ singularity pull --name openmpi-i8.sif docker://


singularity run Vs singularity exec


[SAGA]$ singularity pull --name hello-world.sif shub://vsoch/hello-world
The image created (hello-world.sif) has a user defined command called ""

[SAGA]$ singularity exec hello-world.sif cat /singularity

exec /bin/bash /
[SAGA]$ singularity exec hello-world.sif cat /

echo "RaawwWWWWWRRRR!! Avocado!"

[SAGA]$ singularity run hello-world.sif
RaawwWWWWWRRRR!! Avocado!

With run, the default command is what is excuted,
[SAGA]$ singularity run hello-world.sif cat /etc/os-release
RaawwWWWWWRRRR!! Avocado!
So we need to use exec to get the expected result
[SAGA]$ singularity exec hello-world.sif cat /etc/os-release
VERSION="14.04.6 LTS, Trusty Tahr"

Following are some example use cases we have seen on NRIS HPC systems.


Example 1: A user wants to use different version of the TensorFlow than what is installed in SAGA. So she googles and ends up here There she finds the following command sequence

 docker pull tensorflow/tensorflow:latest  # Download latest stable image
 docker run -it -p 8888:8888 tensorflow/tensorflow:latest-jupyter  # Start Jupyter server

But she knows that we do not have Docker on SAGA so she uses Singularity to pull the image, yes it is possible to pull docker images using singularity

[SAGA]$ singularity pull docker://tensorflow/tensorflow:latest

To test she prints the version

[SAGA]$ singularity run  tensorflow_latest.sif python -c "import tensorflow as tf;print(tf.__version__)"


Example 2: A user needs to use a software that runs only on a specific vesion of Ubuntu

[SAGA]$ singularity pull docker://bioperl/bioperl
[SAGA]$ singularity exec  bioperl_latest.sif cat /etc/os-release
    VERSION="14.04.5 LTS, Trusty Tahr"

[SAGA]$ singularity exec  bioperl_latest.sif perl -e 'use Bio::SeqIO; print join "\n", %INC; print "\n"'


If a ready made image is not available with the software. Then you need to pull Ubuntu image to a machine where you have root access, install the software, repackage it and take it to SAGA. This step is not covered here. If you want to learn how to build your own containers, see our code development guides.

Singularity in Job scripts

This example demonstrates:

  1. how to run a container in a job script

  2. how to execute a command from inside a container: singularity exec <image-name>.sif <command>

  3. that the container runs it’s own operating system (using the same kernel as the host)

  4. that your $HOME directory is mounted in the container by default, which means that it will have access to input files etc. located somewhere in this directory (you will have read/write permissions according to your own user)

First we pull a “hello world” Singularity image from Singularity-Hub. This we need to do from the login node, before the job is submitted. i.e. we do not pull images from within a job.

[SAGA]$ singularity pull --name hello-world.sif shub://vsoch/hello-world

Once we have the SIF file, we can test it out with the following job script on Saga (adjust <myaccount>; on Fram/Betzy you will need to remove the line containing #SBATCH --mem-per-cpu=1000M but the rest should work as is):


#SBATCH --account=<myaccount>
#SBATCH --job-name=singularity-test
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --mem-per-cpu=1000M
#SBATCH --time=00:03:00

echo "what is the operating system on the host?"
cat /etc/os-release

echo "what is the operating system in the container?"
singularity exec hello-world.sif cat /etc/os-release

This produces the following output. Notice how in the container we are on a Ubuntu operating system while the host is CentOS:

check that we can read the current directory from the container:

what is the operating system on the host?
NAME="CentOS Linux"
VERSION="7 (Core)"
ID_LIKE="rhel fedora"
PRETTY_NAME="CentOS Linux 7 (Core)"


what is the operating system in the container?
VERSION="14.04.6 LTS, Trusty Tahr"
PRETTY_NAME="Ubuntu 14.04.6 LTS"


The behavior described in the above example is only accurate if you run it from somewhere within your $HOME directory. If you run it from somewhere else, like /cluster/projects/ or /cluster/work/ you will not enter the container environment from the current directory, but rather from your root $HOME directory, i.e. the output from the first ls command in the script will be equivalent to $ ls $HOME. If you want to access files that are not located in your $HOME you’ll need to --bind that directory explicitly as described below.

Access project area from the container

Singularity container can access the home directory but to access the project directory we need to bind it first.

Lets try it out

[SAGA]$ head -n2 data/input.txt
[SAGA]$ singularity exec hello-world.sif  head -n2 data/input.txt
/usr/bin/head: cannot open 'data/input.txt' for reading: No such file or directory
[SAGA]$ pwd
[SAGA]$ singularity exec hello-world.sif  head -n2 /cluster/projects/nnxxxxk/containers/data/input.txt
/usr/bin/head: cannot open '/cluster/projects/nnxxxxk/containers/data/input.txt' for reading: No such file or directory

Now we use binding to attach local storage and then the container would have access.

[SAGA]$ singularity exec --bind /path/containers/data:/data bioperl_latest.sif head -n2 /data/input.txt

Real world container examples

Other notes

singularity cache