Singularity (now distributed as SingularityCE by Sylabs) is the container runtime built for HPC clusters and scientific computing. It solves a problem Docker did not address: how do you give thousands of unprivileged users on a shared cluster a way to run their own custom software stack without root, without a daemon, and with MPI/GPU/InfiniBand all working transparently? Singularity’s answer is a single-file image format (SIF), root-only image construction, and unprivileged image execution.
How to verify
A working Singularity install responds to these probes:
singularity --version
singularity exec library://alpine cat /etc/os-release
ls /etc/singularity/
singularity buildcfg | head -10
file /path/to/some.sif
The singularity exec command runs a process inside the image’s filesystem without requiring root. buildcfg shows the compile-time options — important because some clusters disable specific features (user-namespace, setuid) for security reasons.
What’s happening
A Singularity image is a single file in SIF format (Singularity Image Format) — a container that holds the rootfs, the metadata, and optionally a signature, all in one. There is no layer storage, no image cache directory, no daemon — just a file. To run it, the user invokes singularity run image.sif and the runtime sets up the mount namespace, binds the user’s home directory into the container, and executes the entry point.
The runtime model differs sharply from Docker. By default Singularity passes the user’s UID and GID directly into the container (no user-namespace remap by default), mounts $HOME, /tmp, and current working directory into the container, and inherits the host’s network namespace. The container is the user — it just sees a different root filesystem.
This is the right model for HPC because: MPI processes need to share IPC and network with each other and the host scheduler; users need their cluster home and scratch directories visible from inside the container; GPUs need to be passed through without device-permission games. Singularity does all this by default.
Image construction requires root (or a setuid Singularity binary, common on HPC clusters configured by admins). Execution does not. This split — root to build, user to run — matches the operational reality of shared clusters.
The mental model
Picture a Singularity workflow:
admin/user with sudo user on login node
│ singularity build app.sif app.def ┐ │
│ │ │ ssh into cluster
▼ │ ▼
SIF file (app.sif) ─── git/registry/scp ────┴───► /home/user/app.sif
│
│ srun singularity run app.sif
▼
compute node
├── MPI ranks across nodes
├── GPU access via --nv
└── /home, /scratch bind-mounted
The image is portable: built once, signed, copied across the cluster’s shared filesystem, run by any user on any compute node.
Operational notes
- SIF as deliverable. Treat the SIF file as the deployment unit. CI builds the SIF, signs it with
singularity sign, pushes it to a registry (Singularity Library, OCI registry, or just an HTTPS URL). Compute nodes pull or scp the SIF and execute. - OCI compat. Singularity can run Docker/OCI images via
singularity exec docker://...— it pulls the layers and assembles them at runtime. Useful for trying images, but for production use, convert to SIF withsingularity pulland use the resulting.siffile. - GPU integration. The
--nvflag (NVIDIA) and--rocmflag (AMD) bind the host’s GPU libraries and devices into the container automatically. No need for nvidia-docker or rocm-runtime separately. - MPI integration. Two patterns: “hybrid” (the host’s MPI launches the container, and the container has a compatible MPI inside) and “bind” (the host’s MPI libs and binaries are bind-mounted into the container, so the same MPI runs from inside). Bind is simpler for clusters with a single MPI stack.
- Signatures and verification.
singularity signadds a PGP signature to the SIF.singularity verifychecks it. Always verify SIF files pulled from external sources before running them on cluster resources. - Read-only by default. Containers are immutable — writes go to a tmpfs overlay that vanishes at exit. For mutable workdirs, use
--writable-tmpfsor bind-mount a writable host path. - No user namespaces. Unlike Podman, default Singularity does not remap UIDs — the user inside is the user outside. Some clusters enable a fakeroot mode that does use user namespaces; check
singularity buildcfg | grep userns.
Common pitfalls
- Treating Singularity images like Docker images — pulling from Docker Hub at runtime on every job. The pull-and-assemble step is slow; convert to SIF once and reuse.
- Building a SIF on the user’s workstation and discovering it fails on the cluster because of glibc version mismatch. Always build on a host with the same or older glibc than the target.
- Running a Singularity image that internally
chroots — fails because Singularity already nests namespaces and chroot is not permitted inside the standard setup. - Forgetting that the host’s
$HOMEis bind-mounted into the container, so~/.cacheand~/.configfrom the host leak into the container. Use--no-homeif isolation matters. - Pulling a Docker image with executables that expect to run as root, then being surprised they fail under Singularity’s default UID-preservation. Use
--fakerootor rebuild without the root assumption.
Stack Harbor supports clients running mixed HPC and standard workloads — clusters where Singularity is the right tool for scientific compute alongside Kubernetes for everything else. See clustered environments for how we run a shared SIF registry, the build-and-sign pipeline, and the Apptainer migration we operate for clusters moving between forks.