Apptainer (formerly Singularity) Documentation
repository·master·Indexed 25 days ago
https://github.com/apptainer/singularityAn open-source container platform designed for shared systems and High Performance Computing (HPC) environments. It features a single-file SIF format, integration with GPUs and parallel filesystems, and support for SCIF images. Documentation covers building images, managing CLI plugins, end-to-end testing, and the MAKEIT build system.
What's inside Apptainer
- MAKEIT is a small, platform-independent build system designed to generate native, non-recursive Makefiles tailored to the host system. It transforms Makefile fragments and module configuration files into Makefiles that are compatible with various versions of Make, including GNU, BSD, and SVR4. It is designed to be lightweight enough to be included directly within individual projects.
Migrate to Apptainer
masterIMPORTANT: Singularity has been renamed to Apptainer. This specific repository is now used for archiving historical release branches and the
masterbranch is not in a consistent state.For all current development, issue reporting, and pull requests, use the official Apptainer repository: https://github.com/apptainer/apptainer. Any issues submitted to this archived repository will be automatically closed.
Build a Singularity image with SCIF support
masterUse the
singularity buildcommand to create a Singularity image from a definition file. When using the Scientific Filesystem (SCIF), you can build containers that include multiple entrypoints, modular environments, libraries, and executables.sudo singularity build cowsay.simg Singularity.cowsayCompile and install Singularity from source
masterTo build and install Singularity from the cloned repository, use
mconfig,make, andmake install.Basic build sequence:
- Run
./mconfigto configure. - Enter the
./builddirdirectory. - Run
make. - Run
sudo make install.
Customizing the build: You can use
./mconfigoptions to modify the build. For example, to specify a different build folder and installation prefix:./mconfig -b ./buildtree -p /usr/localCheck
./mconfig -hfor all available options../mconfig cd ./builddir make sudo make install singularity --version- Run
Run Singularity help end-to-end tests
masterTo run the help content end-to-end tests, use the
makecommand from thebuilddirdirectory with theSINGULARITY_E2Eenvironment variable set.To verify specific tests or run with verbosity, you may need to modify the
Makefileto include the-v(verbose) and-r(run specific test) flags for the Go test command (e.g.,go test -v -r helpContentTests).SINGULARITY_E2E=1 make -C builddir e2e-testAdd a new topic to End-to-End (E2E) testing
masterTo add a new functional area (topic) to the Singularity E2E test suite, follow these steps:
- Register the topic in
suite.go: Add a newt.Runentry insuite.gousing your topic name as a runtime-hook. - Create a topic directory: Create a dedicated directory for your tests (e.g.,
e2e/yourtopic). - Initialize test files: Create a source file for the tests (e.g.,
yourtopic.go) and an optional file for helpers (e.g.,yourtopic_utils.go). - Define the package: Ensure the package declaration in your test file matches the name used in
suite.go. - Configure testing environment: Define a struct to hold testing settings (using
github.com/kelseyhightower/envconfig) and a package-level variable to store them. - Implement the entry point: Create a
RunE2ETests(t *testing.T)function that processes environment variables viaenvconfig.Process("E2E", &testenv)and then triggers individual tests usingt.Run. - Write tests: Implement standard Go tests (e.g.,
func TestYourTopic(t *testing.T)) and call them from your entry point.
- Register the topic in
Report software bugs and code issues via GitHub
masterFor issues involving the Singularity source code or when you need to share debug output, use the GitHub issue boards:
- Singularity Software Issues: Use the Singularity Issues board for most software-related bugs.
- User Documentation Feedback: Use the User Documentation issues board for questions, feedback, or suggestions regarding user guides.
- Admin Documentation Feedback: Use the Admin Documentation issues board for questions, feedback, or suggestions regarding administrative guides.
Naming convention for contributing new definition files
masterWhen contributing new definition files to the
examples/contrib/directory, use a hyphen (-) delimited format for the filename. The format should follow this structure:- Base distribution name and version (e.g.,
centos7orubuntu_trusty) - Target nomenclature describing the container (e.g.,
tensorflow) - Relevant version strings for the application or workflow
- The file must end in
.def
Example filename:
examples/contrib/debian84-tensorflow-0.10.defexamples/contrib/debian84-tensorflow-0.10.def- Base distribution name and version (e.g.,
Install golangci-lint for Singularity development
masterIf you are contributing to the Singularity source code, install
golangci-lintto run local checks. Every pull request must pass these linting checks.After installation, ensure
$(go env GOPATH)/binis added to yourPATH.curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.43.0 echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.bashrc source ~/.bashrcInstall Go for Singularity
masterSingularity is written in Go and may require a version newer than your distribution's repositories. It is recommended to install the latest version from official binaries.
- Download the Go tar.gz archive to
/tmp. - Extract it to
/usr/local(remove any existing/usr/local/gofirst if updating). - Add
/usr/local/go/binto yourPATH.
Note: Ensure you adjust
GOVERSION,OS, andARCHas needed for your environment.export GOVERSION=1.17.3 OS=linux ARCH=amd64 wget -O /tmp/go${GOVERSION}.${OS}-${ARCH}.tar.gz \ https://dl.google.com/go/go${GOVERSION}.${OS}-${ARCH}.tar.gz sudo tar -C /usr/local -xzf /tmp/go${GOVERSION}.${OS}-${ARCH}.tar.gz echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc source ~/.bashrc- Download the Go tar.gz archive to
Build and install Singularity as an RPM
masterOn RHEL, CentOS, or Fedora, you can build Singularity as an RPM package for easier distribution or management via
yum/dnf.Method 1: Build from a release source tarball
- Install
rpm-build,wget, andgolang. - Download the specific version's tarball.
- Run
rpmbuild -tbon the tarball. - Install the resulting RPM using
rpm -ivh.
Method 2: Build from the latest master
- Clone the repo.
- Run
./mconfig --only-rpm(this allows using older system Go versions by applying a patch). - Run
make -C builddir rpm.
Customizing the RPM prefix: Use the
RPMPREFIXvariable during the make step:make -C builddir rpm RPMPREFIX=/opt/singularity# Method 1: From tarball export VERSION=3.8.4 wget https://github.com/hpcng/singularity/releases/download/v${VERSION}/singularity-${VERSION}.tar.gz rpmbuild -tb singularity-${VERSION}.tar.gz sudo rpm -ivh ~/rpmbuild/RPMS/x86_64/singularity-${VERSION}-1.el7.x86_64.rpm # Method 2: From master ./mconfig --only-rpm make -C builddir rpm sudo rpm -ivh ~/rpmbuild/RPMS/x86_64/singularity-3.8.4*.x86_64.rpm- Install
Build a Singularity CLI plugin
masterTo build a CLI plugin, you must use source code that matches the version of the Singularity binary you are targeting. You can identify the exact commit used to build your current Singularity binary by running
singularity version. The suffix (e.g.,.g7998470e7) indicates the Git commit hash.- Clone the Singularity repository.
- Checkout the commit hash identified from your Singularity version.
- Use the
singularity plugin compilecommand pointing to your plugin directory.
Note: Currently, the plugin source code must reside inside the Singularity source code tree during the compilation process.