Newer
Older
[Singularity](http://singularity.lbl.gov/) enables users to have full control of their environment. A non-privileged user can "swap out" the operating system on the host for one they control. So if the host system is running RHEL6 but your application runs in Ubuntu/RHEL7, you can create an Ubuntu/RHEL7 image, install your applications into that image, copy the image to another host, and run your application on that host in it’s native Ubuntu/RHEL7 environment.
Singularity also allows you to leverage the resources of whatever host you are on. This includes HPC interconnects, resource managers, file systems, GPUs and/or accelerators, etc. Singularity does this by enabling several key facets:
* Encapsulation of the environment
* Containers are image based
* No user contextual changes or root escalation allowed
* No root owned daemon processes
## Using Docker Images
Singularity can import, bootstrap, and even run Docker images directly from [Docker Hub](https://hub.docker.com/). You can easily run RHEL7 like this:
CentOS release 6.7 (Final)
[hrb33@r33u01n865 ~]$ ml Singularity
[hrb33@r33u01n865 ~]$ singularity shell docker://centos:latest
library/centos:latest
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:45a2e645736c4c66ef34acce2407ded21f7a9b231199d3b92d6c9776df264729
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Singularity: Invoking an interactive shell within container...
Singularity.centos:latest> cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
hrb33@hrb33-toshiba:/$ cd /tmp/
hrb33@hrb33-toshiba:/tmp$ sudo singularity create /tmp/c7.img
Creating a new image with a maximum size of 768MiB...
Executing image create helper
Formatting image with ext3 file system
Done.
hrb33@hrb33-toshiba:/tmp$ sudo singularity import c7.img docker://centos:latest
library/centos:latest
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:45a2e645736c4c66ef34acce2407ded21f7a9b231199d3b92d6c9776df264729
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Adding Docker CMD as Singularity runscript...
Bootstrap initialization
No bootstrap definition passed, updating container
Executing Prebootstrap module
Executing Postbootstrap module
Done.
hrb33@hrb33-toshiba:/tmp$ sudo singularity shell --writable c7.img
Singularity: Invoking an interactive shell within container...
Singularity.c7.img> mkdir /apps /scratch
Singularity.c7.img> exit
hrb33@hrb33-toshiba:/tmp$ rsync -av c7.img hrb33@login4.salomon:/home/hrb33/c7.img
sending incremental file list
c7.img
sent 805,503,090 bytes received 34 bytes 9,205,749.99 bytes/sec
total size is 805,306,399 speedup is 1.00
```
Accessing /HOME and /SCRATCH Within Container
_____ _
/ ____| | |
| (___ __ _| | ___ _ __ ___ ___ _ __
\___ \ / _` | |/ _ \| '_ ` _ \ / _ \| '_ \
____) | (_| | | (_) | | | | | | (_) | | | |
|_____/ \__,_|_|\___/|_| |_| |_|\___/|_| |_|
http://www.it4i.cz/?lang=en
Last login: Fri Feb 10 14:38:36 2017 from 10.0.131.12
[hrb33@login4.salomon ~]$ ml Singularity
[hrb33@login4.salomon ~]$ singularity shell --bind /scratch --bind /apps --writable c7.img
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Singularity: Invoking an interactive shell within container...
Singularity.c7.img> ls /apps/ -l
total 68
drwx------ 4 root root 29 Sep 29 10:28 SCS
drwxrwxr-x 301 2757 2796 8192 Feb 16 10:58 all
drwxrwxr-x 3 2757 2796 19 Jul 9 2015 base
drwxrwxr-x 16 2757 2796 4096 Nov 24 21:47 bio
drwxrwxr-x 10 2757 2796 116 Apr 8 2016 cae
drwxrwxr-x 18 2757 2796 4096 Jan 17 09:49 chem
drwxrwxr-x 11 2757 2796 122 Dec 7 09:25 compiler
drwxrwxr-x 7 2757 2796 73 Jun 29 2016 data
drwxr-xr-x 7 2757 2796 88 Jan 8 2016 debugger
drwxrwxr-x 38 2757 2796 4096 Feb 16 13:37 devel
drwxrwxr-x 9 2757 2796 130 Jan 9 08:40 easybuild
drwxr-xr-x 11 3900 4011 4096 Feb 15 09:50 gentoo
drwxr-xr-x 10 3900 4011 4096 Feb 10 17:01 gentoo_uv
drwxrwxr-x 5 2757 2796 39 Jan 18 2016 geo
drwxr-xr-x 18 2757 2796 4096 Sep 6 16:03 intel2017
drwxrwxr-x 20 2757 2796 4096 Nov 28 08:50 lang
drwxrwxr-x 31 2757 2796 4096 Dec 7 07:48 lib
drwxrwxr-x 4 2757 2796 32 Nov 9 09:19 licenses
drwxrwxr-x 17 2757 2796 4096 Nov 15 09:24 math
drwxr-xr-x 22 2757 2796 4096 Jan 19 13:15 modules
drwxrwxr-x 8 2757 2796 82 Apr 18 2016 mpi
drwxrwxr-x 13 2757 2796 4096 Oct 24 09:08 numlib
drwxrwxr-x 10 2757 2796 108 Feb 3 11:01 perf
drwxrwxr-x 5 2757 2796 41 Jan 17 09:49 phys
drwxrwxr-x 2 2757 2796 6 Feb 3 11:01 prace
drwxr-xr-x 4 root root 36 Jun 18 2015 sw
drwxrwxr-x 5 2757 2796 49 Feb 15 2016 system
drwxr-xr-x 3 root root 19 Dec 4 2015 test
drwxrwxr-x 13 2757 2796 138 May 31 2016 toolchain
drwxrwxr-x 39 2757 2796 4096 Feb 3 11:27 tools
drwxr-xr-x 4 root root 31 Aug 11 2015 user
drwxrwxr-x 21 2757 2796 4096 Jan 5 18:56 uv
drwxrwxr-x 40 2757 2796 4096 Feb 3 11:01 vis
Singularity.c7.img> ls /scratch/ -l
total 32
drwx------ 3 root root 4096 Aug 15 2016 backup
drwxr-x--- 2 root root 4096 Dec 5 10:34 sys
drwxrwxrwt 154 root root 20480 Feb 14 14:03 temp
drwxr-xr-x 4 root root 4096 Jan 25 10:48 work