Apptainer
Apptainer (formerly known as singularity) is a container image system favoured on HPC systems.
For those already familar with docker or podman containers, apptainer uses a slightly different approach:
- Runs without elevated (root) privileges
- Images are saved as physical files to disk
About the images
For overall flexibility, the OpenFOAM apptainer support is provided via description files in the packaging/containers repository rather than pre-assembled images. The download bandwidth will be essentially identical in both cases.
The packages do not contain
visualization (eg, ParaView/runTimePostProcessing) or
external-solver (eg, PETSc) modules:
see the corresponding FAQ
Creating an OpenFOAM apptainer image
Creating an apptainer image is a simple as downloading the container description files from the packaging/containers repository.
Select and edit the definitions to suit your purposes and build the image. For example,
apptainer build --fakeroot openfoam2406.sif openfoam-run_rocky.def
which will build the file openfoam2406.sif
from the image
description file, using the RockyLinux base image.
A .sif
extension (singularity image format) is often used for the
apptainer files but is not required.
Notes
It is recommended to base OpenFOAM apptainer images on the framework provided by the packaging/containers repository. In addition to providing the plain sequencing of package installation, the included file assets (openfoam-files.rc/) provide for a coherent runtime environment with the OpenFOAM environment properly initialised.
Running OpenFOAM in an apptainer
Running OpenFOAM in an apptainer is absolutely straight
forward.
Simply place the generated apptainer file somewhere convenient in your
path (eg, $HOME/bin
etc) and use it.
For example,
$ openfoam2406.sif
This will open an interactive shell with the OpenFOAM environment active, with the current local directory mounted within the container.
Running interactively
Running an interactive shell with the OpenFOAM environment active is the default behaviour for the image and the internal run-script.
For example,
$ openfoam2406.sif
Running non-interactively
It is also possible to use the image in batch mode. For example,
$ openfoam2406.sif blockMesh -help
It is also possible to use as for running shell scripts. For example,
$ openfoam2406.sif -c './Allrun'
Note that the entry point within the image itself also has some option handling. For example,
$ openfoam2406.sif -help
Copyright (C) 2022-2024 OpenCFD Ltd.