Singularity is a container technology that does not require root permissions to run, so it is compatible with often permission-constrained High-Performance Compute (HPC) environments. It works on MacOS, Windows and Linux. Debian presents it as the package singularity-container. Please also inspect backports.debian.org for latest versions backported to earlier Debian releases.

Singularity has several ways to build its containers:

Once the image is available, you either work with it by asking for a shell to execute in the container or to execute a binary of the container directly. By default, the binary as access to the same files that you have access to. But this can be constrained as appropriate in the bootstrap definition file.

Example 1: Extend a Docker image

A bootstrap does not seem to take any time than a start from an existing docker image. Except for the specification of the bootstrap, the exact same commands are to be executed.

1. Install the Debian package for singularity sudo apt install singularity-container

2. Prepare the definition file

cat >> Singularity_Docker.def
Bootstrap: docker
From: debian:latest

3. Build the container sudo singularity build /tmp/mycontainer.sif Singularity_Docker.def

4. Get a shell executed within the container singularity shell /tmp/mycontainer.sif

Example 2: Build from scratch

A bootstrap does not seem to take more time than a start from an existing docker image. Except for the specification of the build, the exact same commands are to be executed.

1. Install the Debian package for singularity sudo apt-get install singularity-container

2. Prepare definition file

cat >> Singularity_Bootstrap.def
Bootstrap: debootstrap
MirrorURL: http://deb.debian.org/debian
OSVersion: unstable
Include: vim

3. Build the container sudo singularity build /tmp/mycontainer.sif Singularity_Bootstrap.def

4. Get a shell executed within the container singularity shell /tmp/mycontainer.sif

The decision for Docker is easy for best possible compatibility with an earlier effort or when reorganising the data is considered too tedious.

In analogy to the already so popular Docker technology, Singularity also features a repository of readily usable/extendable images at https://singularity-hub.org.

Example 3: Build a larger image from scratch

The debootstrap tool only installs strong dependencies (Depends, not Recommends). However, some metapackages such as the ones used in the Debian Blends distributions rely on Recommends dependencies.

In the following example, we bootstrap the stable version of Debian, and install the med-cloud package (that pulls in a lot of bioinformatics tools).

Bootstrap: debootstrap
MirrorURL: http://deb.debian.org/debian
OSVersion: stable

%post
    apt -y update
    apt -y install med-cloud

See also

Please address https://sylabs.io/docs/ and https://singularityhub.github.io/singularityhub-docs/docs/faq for more. Additional tantalizing instructions for HPC environments you find on https://hpc.nih.gov/apps/singularity.html and https://github.com/NIH-HPC/Singularity-Tutorial.