Singularity containers installation

This page describes the installation of Singularity container software on CentOS/RHEL 7.


Installation of Singularity

See the install-linux page about download of the releases tar-ball and then Build an RPM from source.

Notice: The EPEL repository only contains an outdated RPM:

# yum list singularity
Available Packages
singularity.x86_64     2.2.1-3.el7   epel

Warning: Singularity 2.4 and later will not work on CentOS/RHEL 7.4 if installed on an NFS server, see this thread.

Build Singularity RPMs

To build RPM packages, first install some required tools:

yum groupinstall 'Development Tools'
yum install libarchive-devel libseccomp-devel

Follow the instructions on the releases page:

rpmbuild -tb singularity-3.0.1.tar.gz

The RPMs will be in the ~/rpmbuild/RPMS/x86_64/ directory.

Install the RPM:

yum install singularity-3.*.el7.x86_64.rpm

Note: This will install the command completion file /etc/bash_completion.d/singularity for your convenience.

Some additional tools are required to run Singularity:

yum install epel-release
yum install debootstrap.noarch
yum install wget

As a normal user, make a test run:

user# singularity run docker://godlovedc/lolcow

Setting up sudo to run Singularity

Root priviledge through sudo is required to build containers. As root, use the command visudo to edit /etc/sudoers to include a line for user XXX:

XXX  ALL=(ALL) /usr/bin/singularity

To permit a UNIX group, use the % prefix to the group name:

%groupname  ALL=(ALL) /usr/bin/singularity

Singularity tutorial

The singularity RPM package contains examples in:


First try out the Singularity_tutorial (skip to Hour 2):

mkdir lolcow
cp /usr/share/doc/singularity-2.*/examples/ubuntu/Singularity lolcow/
cd lolcow
sudo singularity build --sandbox lolcow Singularity

and then follow the Singularity_tutorial.

Building tutorial containers

Warning: Building a Singularity such as lolcow.img requires root permissions to the working directory's file system. If you try to build a container on an NFS-mounted directory without root permissions to the file system (this should be configured for security reasons), you will get an error message Operation not permitted:

# sudo singularity build --sandbox lolcow Singularity
[sudo] password for XXX:
Building into existing container: lolcow
Using container recipe deffile: Singularity
tar: .: Cannot utime: Permission denied
tar: .: Cannot change ownership to uid 0, gid 0: Operation not permitted
tar: Exiting with failure status due to previous errors
ERROR: Failed to export contents of Singularity to lolcow
ABORT: Aborting with RETVAL=255

Conclusion: You must build Singularity containers on a file system where the sudo command has root permissions. This would normally require a directory on local storage such as /tmp or some scratch space.

Container build environment

It’s commonly the case that you want to customize your build environment, such as specifying a custom cache directory for layers, or sending your Docker Credentials to the registry endpoint. This is documented in the Build_environment page.

Container examples

Here are some experiences with building Singularity 2.4 containers.

CentOS containers

You can build containers using the yum_bootstrap_module:

Bootstrap: yum

The example file can be used for CentOS 7:


However, older releases don't work with this example, see and the yum_bootstrap_module Notes section. One must wipe and rebuild the RPM database for the distribution like in the example for CentOS 6:

BootStrap: yum
OSVersion: 6
Include: yum
  echo "Hello from inside the container"
  rm -rf /var/lib/rpm/__*
  touch /var/lib/rpm/*
  rpm --rebuilddb
  rpm -qa
  yum -y install vim-minimal

Docker containers for CentOS can be run from the CentOS library, for example a 6.9 container:

singularity run docker://centos:centos6.9

Niflheim: Singularity_installation (last edited 2018-11-23 08:28:49 by OleHolmNielsen)