Skip to content

Apptainer/Singularity

Apptainer (formerly known as Singularity)

Apptainer/Singularity [1][2] is a container framework, that aims for reproducibility and portability. It has been comingly known as "Singularity" but has been renamed to Apptainer in 2022 due to legal constraints. In general, just the name changed and all options are the same.

An Apptainer container can be a single local image file (or as unpacked directory tree), thus the image can be moved around and started into a container instance depending on some remote repository.

With Apptainer installed on a somewhat recent Linux distribution/kernel like CentOS 7 and newer, a 'normal' user can run Apptainer containers without the need for some running daemon process or for additional permissions/groups, .e.,

your user > apptainer shell /cvmfs/atlas.cern.ch/repo/containers/fs/singularity/x86_64-centos6
your user > apptainer shell /cvmfs/atlas.cern.ch/repo/containers/fs/singularity/x86_64-centos6

To build an own container, one can write a Apptainer recipe (the recipe file get's normally named just 'Apptainer') to start from an existing container either from Apptainer or from Docker images and extend it as you wish

> sudo apptainer build MyContainerFile.img Apptainer
> sudo apptainer build MyContainerFile.img Apptainer

as more abilities are needed to build a new container than for running a container, the build needs root permissions → thus, you should be able to run an existing container out-of-the-box on an somehwat recent Linux machine with Apptainer installed but you will need a machine with sudo/wheel rights, if you want to build your own container.

For more details check the sub-pages on Apptainer / Building / Isolation / Bootstrapping...

Apptainer Cache and TMP Directories

If you pull a lot of Docker images/containers or very large images, your Apptainer directories to build and cache the files might get to small.

To change these directories to something larger, create the new target directories on a suitable storage and export the following environment variables

export APPTAINER_TMPDIR=/PATH/TO/STORAGE/apptainer/tmp

export APPTAINER_CACHEDIR=/PATH/TO/STORAGE/apptainer/cache

on updated systems with Apptainer renamed to Apptainer, the corresponding APPTAINER_ environment variables should work as well (APPTAINER_ environment variables are evaluated as well)

export APPTAINER_TMPDIR=/PATH/TO/STORAGE/apptainer/tmp

export APPTAINER_CACHEDIR=/PATH/TO/STORAGE/apptainer/cache

(for problems with not enough space in a container's temporary directoreis see Problems in Containers with 'No space left on device' due to limited TMP directories )