Singularity

Singularity

Singularity is a container platform which allows users to have full control of the environment in which their application runs. It is a safe and secure alternative to Docker, as Docker requires root access for much of its functionality, whereas Singularity allows the safe running of application bundles without requiring root privileges. It is even possible to convert Docker images to Singularity.

Our public computing systems offer Singularity at this time in order to enable the portability of highly specialized applications without some of the risks involved with other solutions such as Docker.

In order to use Singularity, you will need to create an image of your application. This image must be created in either a Linux, Mac or Windows environment, and then can be moved to any system on which Singularity is installed, such as our public computing systems, where it can be executed without administrative privileges. Details on downloading, using, and installing Singularity can be found on the Singularity page at LBL.

Using Singularity in CS

First, install Singularity on the system where your application is running. Install instructions for:

Next, create and bootstrap an image on your local machine where you have root/admin privileges.

$ singularity create centos.img
Creating a new image with a maximum size of 768MiB...
Executing image create helper
Formatting image with ext3 file system
Done.

$ singularity bootstrap centos.img centos.def
Bootstrap initialization
Checking bootstrap definition
Executing Prebootstrap module
Executing Bootstrap 'yum' module
Found YUM at: /bin/yum
base                                                                                                  | 3.6 kB  00:00:00
(1/2): base/x86_64/group_gz                                                                           | 155 kB  00:00:00
(2/2): base/x86_64/primary_db

............

After you have copied (with scp) an image to cycles, you can go ahead and run it. 

$ singularity shell centos.img
WARNING: Not mounting home directory: bind point does not exist in container: /u
WARNING: Could not chdir to home directory: /u/joeuser
Singularity: Invoking an interactive shell within container...

Singularity.centos.img>

$ singularity exec centos.img cat /etc/redhat-release
WARNING: Not mounting home directory: bind point does not exist in container: /u
WARNING: Could not chdir to home directory: /u/joeuser
CentOS Linux release 7.3.1611 (Core)

The WARNING message can be ignored as the original image was created on a system without mounted home directories.  

It is also possible to convert docker images to Singularity.

Helpful links

https://www.youtube.com/watch?v=xuIQoth0r4E

https://github.com/singularityware/singularity

http://singularity.lbl.gov/