Singularity Container Documentation
Release 2.6
User Docs
Sep 20, 2018
CONTENTS
1
2
Quick Start
1.1 Quick Installation Steps . . . . . . . . . . . . . . . . .
1.2 Overview of the Singularity Interface . . . . . . . . . .
1.3 Download pre-built images . . . . . . . . . . . . . . . .
1.4 Interact with images . . . . . . . . . . . . . . . . . . .
1.4.1
Shell . . . . . . . . . . . . . . . . . . . . . . .
1.4.2
Executing Commands . . . . . . . . . . . . . .
1.4.3
Running a container . . . . . . . . . . . . . . .
1.4.4
Working with Files . . . . . . . . . . . . . . .
1.5 Build images from scratch . . . . . . . . . . . . . . . .
1.5.1
Sandbox Directory . . . . . . . . . . . . . . .
1.5.2
Writable Image . . . . . . . . . . . . . . . . .
1.5.3
Converting images from one format to another .
1.5.4
Singularity Recipes . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1
1
1
3
4
4
5
5
5
6
6
6
6
7
Introduction
2.1 Welcome to Singularity! . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.1
Mobility of Compute . . . . . . . . . . . . . . . . . . . . . . . .
2.1.2
Reproducibility . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.3
User Freedom . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.4
Support on Existing Traditional HPC . . . . . . . . . . . . . . . .
2.2 A High Level View of Singularity . . . . . . . . . . . . . . . . . . . . . .
2.2.1
Security and privilege escalation . . . . . . . . . . . . . . . . . .
2.2.2
The Singularity container image . . . . . . . . . . . . . . . . . .
2.2.2.1 Copying, sharing, branching, and distributing your image
2.2.2.2 Supported container formats . . . . . . . . . . . . . . .
2.2.2.3 Supported Uniform Resource Identifiers (URI) . . . . . .
2.2.3
Name-spaces and isolation . . . . . . . . . . . . . . . . . . . . .
2.2.4
Compatibility with standard work-flows, pipes and IO . . . . . . .
2.2.5
The Singularity Process Flow . . . . . . . . . . . . . . . . . . . .
2.3 The Singularity Usage Workflow . . . . . . . . . . . . . . . . . . . . . .
2.3.1
Singularity Commands . . . . . . . . . . . . . . . . . . . . . . .
2.4 Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5 About . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5.1
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5.2
Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5.2.1 The Singularity Solution . . . . . . . . . . . . . . . . . .
2.5.2.2 Portability and Reproducibility . . . . . . . . . . . . . .
2.5.3
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5.3.1 Encapsulation of the environment . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
9
9
9
9
10
10
10
10
11
11
11
11
12
12
13
13
14
15
15
15
15
15
17
18
18
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
i
2.5.3.2 Containers are image based . . . . . . . . . . . . . . . . . . . . . .
2.5.3.3 No user contextual changes or root escalation allowed . . . . . . . .
2.5.3.4 No root owned daemon processes . . . . . . . . . . . . . . . . . . .
2.5.4
Use Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5.4.1 BYOE: Bring Your Own Environment . . . . . . . . . . . . . . . .
2.5.4.2 Reproducible science . . . . . . . . . . . . . . . . . . . . . . . . .
2.5.4.3 Static environments (software appliances) . . . . . . . . . . . . . .
2.5.4.4 Legacy code on old operating systems . . . . . . . . . . . . . . . .
2.5.4.5 Complicated software stacks that are very host specific . . . . . . .
2.5.4.6 Complicated work-flows that require custom installation and/or data
2.5.5
License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5.6
Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
4
ii
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
18
18
18
19
19
19
19
19
20
20
20
20
Installation
3.1 Before you begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 Install from a tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3 Install a specific release . . . . . . . . . . . . . . . . . . . . . . . . . .
3.4 Install the development branch . . . . . . . . . . . . . . . . . . . . . . .
3.5 Remove an old version . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.6 Install on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.6.1
Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.6.2
Singularity Vagrant Box . . . . . . . . . . . . . . . . . . . . .
3.7 Install on Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.7.1
Installation from Source . . . . . . . . . . . . . . . . . . . . .
3.7.1.1 Option 1: Download latest stable release . . . . . . . .
3.7.1.2 Option 2: Download the latest development code . . . .
3.7.1.3 Prefix in special characters . . . . . . . . . . . . . . .
3.7.1.4 Updating . . . . . . . . . . . . . . . . . . . . . . . . .
3.7.2
Debian Ubuntu Package . . . . . . . . . . . . . . . . . . . . .
3.7.2.1 Testing first with Docker . . . . . . . . . . . . . . . .
3.7.2.2 Adding the Mirror and installing . . . . . . . . . . . .
3.7.3
Build an RPM from source . . . . . . . . . . . . . . . . . . . .
3.7.4
Build an DEB from source . . . . . . . . . . . . . . . . . . . .
3.7.5
Install on your Cluster Resource . . . . . . . . . . . . . . . . .
3.8 Install on Mac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.8.1
Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.8.2
Option 1: Singularity Vagrant Box . . . . . . . . . . . . . . . .
3.8.3
Option 2: Vagrant Box from Scratch (more advanced alternative)
3.9 Requesting an Installation . . . . . . . . . . . . . . . . . . . . . . . . .
3.9.1
How do I ask for Singularity on my local resource? . . . . . . .
3.9.2
Information Resources . . . . . . . . . . . . . . . . . . . . . .
3.9.2.1 Background . . . . . . . . . . . . . . . . . . . . . . .
3.9.2.2 Security . . . . . . . . . . . . . . . . . . . . . . . . .
3.9.2.3 Presentations . . . . . . . . . . . . . . . . . . . . . . .
3.9.3
Installation Request . . . . . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
21
21
21
22
22
22
23
23
23
24
24
25
25
25
26
26
26
26
28
29
29
29
29
30
31
32
32
32
32
32
32
32
Build a Container
4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Downloading a existing container from Singularity Hub . . .
4.3 Downloading a existing container from Docker Hub . . . . .
4.4 Creating --writable images and --sandbox directories
4.4.1 --writable . . . . . . . . . . . . . . . . . . . .
4.4.2 --sandbox . . . . . . . . . . . . . . . . . . . . .
4.5 Converting containers from one format to another . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
35
35
35
37
37
37
37
38
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
4.6
4.7
5
6
7
8
9
Building containers from Singularity recipe files
4.6.1 --force . . . . . . . . . . . . . . . .
4.6.2 --section . . . . . . . . . . . . . .
4.6.3 --notest . . . . . . . . . . . . . . .
4.6.4 --checks . . . . . . . . . . . . . . .
More Build topics . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
38
39
39
39
39
40
Build Environment
5.1 Cache Folders . . . . . . . . . .
5.2 Temporary Folders . . . . . . . .
5.3 Pull Folder . . . . . . . . . . . .
5.4 Environment Variables . . . . . .
5.5 Cache . . . . . . . . . . . . . . .
5.5.1
Defaults . . . . . . . . .
5.5.1.1 Docker . . . . .
5.5.1.2 Singularity Hub
5.5.2
General . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
41
41
41
42
42
42
43
43
43
44
Container Recipes
6.1 Overview . . . . . . . . . . . .
6.1.1
Header . . . . . . . . .
6.1.2
Sections . . . . . . . .
6.1.2.1 %help . . . .
6.1.2.2 %setup . . . .
6.1.2.3 %files . . . .
6.1.2.4 %labels . . .
6.1.2.5 %environment
6.1.2.6 %post . . . .
6.1.2.7 %runscript . .
6.1.2.8 %test . . . . .
6.2 Apps . . . . . . . . . . . . . .
6.3 Examples . . . . . . . . . . . .
6.4 Best Practices for Build Recipes
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
45
45
45
46
46
47
47
49
50
51
52
54
54
57
57
Singularity Flow
7.1 Building Images . . . . . . . . . . . . . . . . . .
7.1.1
The Singularity Flow . . . . . . . . . . .
7.1.2
1. Development Commands . . . . . . .
7.1.2.1 Sandbox Folder . . . . . . . . .
7.1.2.2 Writable Image . . . . . . . . .
7.1.3
2. Production Commands . . . . . . . . .
7.1.3.1 Recommended Production Build
7.1.3.2 Production Build from Sandbox .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
59
59
59
60
60
62
63
63
64
Bind Paths and Mounts
8.1 Overview . . . . . . . . . . . . . . . .
8.1.1
System-defined bind points . .
8.1.2
User-defined bind points . . .
8.1.2.1 Specifying Bind Paths
8.1.2.2 Binding with Overlay
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
65
65
65
65
65
66
Persistent Overlays
9.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.2 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
69
69
69
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
iii
10 Running Services
10.1 Why container instances? . . . . .
10.2 Container Instances in Singularity .
10.3 Nginx “Hello-world” in Singularity
10.4 Putting all together . . . . . . . . .
10.4.1 Building the image . . . .
10.4.2 Running the Server . . . .
10.4.3 Making it Pretty . . . . . .
10.5 Important Notes . . . . . . . . . .
.
.
.
.
.
.
.
.
71
71
71
73
74
74
76
77
78
11 Container Checks
11.1 Tags and Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.2 What checks are available? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
79
79
80
12 Environment and Metadata
12.1 Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12.2 Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12.3 Container Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
81
81
82
83
13 Reproducible SCI-F Apps
13.1 Why do we need SCI-F? . . . . . .
13.1.1 Mixed up Modules . . . .
13.1.2 Container Transparency . .
13.1.3 Container Modularity . . .
13.1.4 Sections . . . . . . . . . .
13.1.5 Interaction . . . . . . . . .
13.2 SCI-F Example: Cowsay Container
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
85
85
85
86
88
90
90
92
14 Singularity and Docker
14.1 TLDR (Too Long Didn’t Read) . . . . . . . . . . .
14.2 Import a Docker image into a Singularity Image . .
14.3 Quick Start: The Docker Registry . . . . . . . . . .
14.4 The Build Specification file, Singularity . . . . . . .
14.5 How does the runscript work? . . . . . . . . . . . .
14.6 How do I specify my Docker image? . . . . . . . .
14.7 Custom Authentication . . . . . . . . . . . . . . . .
14.7.1 Authentication in the Singularity Build File
14.7.2 Authentication in the Environment . . . . .
14.7.3 Testing Authentication . . . . . . . . . . .
14.8 Best Practices . . . . . . . . . . . . . . . . . . . . .
14.8.1 1. Installation to Root . . . . . . . . . . . .
14.8.2 2. Library Configurations . . . . . . . . . .
14.8.3 3. Don’t install to $HOME or $TMP . . . .
14.9 Troubleshooting . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
95
95
95
96
97
98
99
99
100
100
100
100
101
101
101
101
15 Troubleshooting
15.1 No space left on device . . . . . . . . . . . . . . . . . . .
15.2 Segfault on Bootstrap of Centos Image . . . . . . . . . .
15.3 How to use Singularity with GRSecurity enabled kernels .
15.4 The container isn’t working on a different host! . . . . . .
15.5 Invalid Argument or Unknown Option . . . . . . . . . . .
15.6 Error running Singularity with sudo . . . . . . . . . . . .
15.7 How to resolve “Too many levels of symbolic links” error
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
103
103
103
104
104
105
105
105
16 Appendix
iv
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
107
16.1 build-docker-module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.1.2 Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.1.3 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.2 build-shub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.2.2 Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.2.3 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.3 build-localimage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.3.2 Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.3.3 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.4 build-yum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.4.2 Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.4.3 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.5 build-debootstrap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.5.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.5.2 Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.5.3 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.6 build-arch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.6.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.6.2 Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.6.3 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.7 build-busybox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.7.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.7.2 Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.7.3 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.8 build-zypper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.8.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.8.2 Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.9 Singularity Action Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.9.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10 Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.1 Command Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.1.1 The Singularity command . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.1.1.1 Options and argument processing . . . . . . . . . . . . . . . . . . . .
16.10.1.1.2 Singularity Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.1.2 Commands Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.1.3 Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.2 build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.2.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.2.2.1 Download an existing container from Singularity Hub or Docker Hub
16.10.2.2.2 Create –writable images and –sandbox directories . . . . . . . . . . .
16.10.2.2.3 Convert containers from one format to another . . . . . . . . . . . . .
16.10.2.2.4 Build a container from a Singularity recipe . . . . . . . . . . . . . . .
16.10.3 exec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.3.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.3.1.1 Printing the OS release inside the container . . . . . . . . . . . . . .
16.10.3.1.2 Printing the OS release for a running instance . . . . . . . . . . . . .
16.10.3.1.3 Runtime Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.3.1.4 Special Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.3.1.5 A Python example . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
107
107
107
108
108
108
108
108
109
109
109
109
109
109
109
110
110
110
110
111
111
111
111
111
111
112
112
112
112
112
112
113
113
114
114
114
114
115
115
116
117
117
117
117
117
117
117
118
118
118
118
118
118
119
v
16.10.3.1.6 A GPU example . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.4 inspect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.4.1 JSON Api Standard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.4.2 Inspect Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.4.2.1 Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.4.2.2 Runscript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.4.2.3 Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.4.2.4 Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.4.2.5 Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.4.2.6 Deffile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.5 pull . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.5.1 Singularity Hub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.5.1.1 How do tags work? . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.5.1.2 Image Names . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.5.1.3 Custom Name . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.5.1.4 Name by commit . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.5.1.5 Name by hash . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.5.1.6 Pull to different folder . . . . . . . . . . . . . . . . . . . . . . . .
16.10.5.1.7 Pull by commit . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.5.2 Docker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.6 run . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.6.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.6.2 Runtime Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.6.3 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.6.3.1 Defining the Runscript . . . . . . . . . . . . . . . . . . . . . . .
16.10.7 shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.7.1 Change your shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.7.1.1 Bash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.10.7.2 Shell Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.11 Image Command Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.11.1 image.export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.11.2 image.expand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.11.2.1 Increasing the size of an existing image . . . . . . . . . . . . . . . . . . . .
16.11.3 image.import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.11.4 image.create . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.11.4.1 Creating a new blank Singularity container image . . . . . . . . . . . . . .
16.11.4.1.1 Overwriting an image with a new one . . . . . . . . . . . . . . .
16.12 Instance Command Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.12.1 instance.start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.12.1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.12.1.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.12.1.2.1 Start an instance called cow1 from a container on Singularity Hub
16.12.1.2.2 Start an interactive shell within the instance that you just started .
16.12.1.2.3 Execute the runscript within the instance . . . . . . . . . . . . . .
16.12.1.2.4 Run a command within a running instance . . . . . . . . . . . . .
16.12.2 instance.list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.12.2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.12.2.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.12.2.2.1 Start a few named instances from containers on Singularity Hub .
16.12.2.2.2 List running instances . . . . . . . . . . . . . . . . . . . . . . . .
16.12.3 instance.stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.12.3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.12.3.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.12.3.2.1 Start a few named instances from containers on Singularity Hub .
vi
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
120
122
122
123
124
124
125
126
126
127
128
128
128
128
129
129
129
129
130
130
132
132
132
132
133
134
135
135
135
137
137
137
137
138
138
139
140
140
140
141
141
141
141
141
142
142
142
142
143
143
143
143
143
143
16.12.3.2.2 Stop a single instance . .
16.12.3.2.3 Stop all running instances
16.13 Deprecated . . . . . . . . . . . . . . . . . . . . . .
16.13.1 bootstrap . . . . . . . . . . . . . . . . . .
16.13.1.1 Quick Start . . . . . . . . . . . . .
17 Contributing
17.1 Support Singularity . . . . . . . . . . . . . . . . .
17.1.1 Singularity Google Group . . . . . . . .
17.1.2 Singularity on Slack . . . . . . . . . . .
17.2 Contribute to the code . . . . . . . . . . . . . . .
17.2.1 Step 1. Fork the repo . . . . . . . . . . .
17.2.2 Step 2. Set up your config . . . . . . . .
17.2.3 Step 3. Checkout a new branch . . . . . .
17.2.4 Step 4. Make your changes . . . . . . . .
17.2.5 Step 5. Push your branch to your fork . .
17.2.6 Step 6. Submit a Pull Request . . . . . .
17.2.7 Support, helping and spreading the word!
17.3 Contributing to Documentation . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
143
144
144
144
144
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
147
147
147
147
147
148
148
150
150
151
151
151
151
18 FAQ
153
18.1 General Singularity Info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
18.1.1 Why the name “Singularity”? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
18.1.2 What is so special about Singularity? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
18.1.3 Which namespaces are virtualized? Is that select-able? . . . . . . . . . . . . . . . . . . . . 154
18.1.4 What Linux distributions are you trying to get on-board? . . . . . . . . . . . . . . . . . . . 154
18.1.5 How do I request an installation on my resource? . . . . . . . . . . . . . . . . . . . . . . . 154
18.2 Basic Singularity usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
18.2.1 Do you need administrator privileges to use Singularity? . . . . . . . . . . . . . . . . . . . 154
18.2.2 What if I don’t want to install Singularity on my computer? . . . . . . . . . . . . . . . . . . 154
18.2.3 Can you edit/modify a Singularity container once it has been instantiated? . . . . . . . . . . 155
18.2.4 Can multiple applications be packaged into one Singularity Container? . . . . . . . . . . . . 155
18.2.5 How are external file systems and paths handled in a Singularity Container? . . . . . . . . . 155
18.2.6 How does Singularity handle networking? . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
18.2.7 Can Singularity support daemon processes? . . . . . . . . . . . . . . . . . . . . . . . . . . 155
18.2.8 Can a Singularity container be multi-threaded? . . . . . . . . . . . . . . . . . . . . . . . . 155
18.2.9 Can a Singularity container be suspended or check-pointed? . . . . . . . . . . . . . . . . . 156
18.2.10 Are there any special requirements to use Singularity through an HPC job scheduler? . . . . 156
18.2.11 Does Singularity work in multi-tenant HPC cluster environments? . . . . . . . . . . . . . . 156
18.2.12 Can I run X11 apps through Singularity? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
18.2.13 Can I containerize my MPI application with Singularity and run it properly on an HPC system?156
18.2.14 Why do we call ‘mpirun’ from outside the container (rather than inside)? . . . . . . . . . . 156
18.2.15 Does Singularity support containers that require GPUs? . . . . . . . . . . . . . . . . . . . . 157
18.3 Container portability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
18.3.1 Are Singularity containers kernel-dependent? . . . . . . . . . . . . . . . . . . . . . . . . . 157
18.3.2 Can a Singularity container resolve GLIBC version mismatches? . . . . . . . . . . . . . . . 157
18.3.3 What is the performance trade off when running an application native or through Singularity? 157
18.4 Misc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
18.4.1 Are there any special security concerns that Singularity introduces? . . . . . . . . . . . . . 158
vii
viii
CHAPTER
ONE
QUICK START
This guide is intended for running Singularity on a computer where you have root (administrative) privileges. If you
are learning about Singularity on a system where you lack root privileges, you can still complete the steps that do not
require the sudo command. If you need to request an installation on your shared resource, check out our requesting
an installation help page for information to send to your system administrator.
1.1 Quick Installation Steps
There are many ways to install Singularity but this quick start guide will only cover one. You will need git to
download the source code and the appropriate tools and libraries. Create and move to a working directory and enter
the following steps.
git clone https://github.com/sylabs/singularity.git
cd singularity
git fetch --all
git checkout 2.6.0
./autogen.sh
./configure --prefix=/usr/local
make
sudo make install
Singularity must be installed as root to function properly.
1.2 Overview of the Singularity Interface
Singularity’s command line interface allows you to build and interact with containers transparently. You can run
programs inside a container as if they were running on your host system. You can easily redirect IO, use pipes, pass
arguments, and access files, sockets, and ports on the host system from within a container. The --help option gives
an overview of Singularity options and subcommands as follows:
$ singularity --help
USAGE: singularity [global options...] [command options...] ...
(continues on next page)
1
Singularity Container Documentation, Release 2.6
(continued from previous page)
GLOBAL OPTIONS:
-d|--debug
Print debugging information
-h|--help
Display usage summary
-s|--silent
Only print errors
-q|--quiet
Suppress all normal output
--version
-v|--verbose
Show application version
Increase verbosity +1
-x|--sh-debug Print shell wrapper debugging information
GENERAL COMMANDS:
help
Show additional help for a command or container
selftest
Run some self tests for singularity install
CONTAINER USAGE COMMANDS:
exec
Execute a command within container
run
Launch a runscript within container
shell
Run a Bourne shell within container
test
Launch a testscript within container
CONTAINER MANAGEMENT COMMANDS:
apps
List available apps within a container
bootstrap
*Deprecated* use build instead
build
Build a new Singularity container
check
Perform container lint checks
inspect
Display a container's metadata
mount
Mount a Singularity container image
pull
Pull a Singularity/Docker container to $PWD
COMMAND GROUPS:
image
Container image command group
(continues on next page)
2
Chapter 1. Quick Start
Singularity Container Documentation, Release 2.6
(continued from previous page)
instance
Persistent instance command group
CONTAINER USAGE OPTIONS:
see singularity help
For any additional help or support visit the Singularity
website: https://github.com/sylabs/singularity
For any additional help or support visit the Singularity website: https://www.sylabs.io/contact/ Singularity uses positional syntax (i.e. where the option is on the command line matters). Global options follow the singularity
invocation and affect the way that Singularity runs any command. Then commands are passed followed by their options. For example, to pass the --debug option to the main singularity command and run Singularity with
debugging messages on:
$ singularity --debug run shub://GodloveD/lolcow
And to pass the --containall option to the run command and run a Singularity image in an isolated manner:
$ singularity run --containall shub://GodloveD/lolcow
To learn more about a specific Singularity command, type one of the following:
$ singularity help
$ singularity --help
$ singularity -h
$ singularity --help
$ singularity -h
Users can also write help docs specific to a container or for an internal module called an app. If those help docs exist
for a particular container, you can view them like so.
$ singularity help container.simg
# See the container's help, if provided
$ singularity help --app foo container.simg
# See the help for foo, if provided
1.3 Download pre-built images
You can use the pull and build commands to download pre-built images from an external resource like Singularity Hub
or Docker Hub. When called on a native Singularity images like those provided on Singularity Hub, pull simply
downloads the image file to your system.
$ singularity pull shub://vsoch/hello-world
˓→world-master.simg
# pull with default name, vsoch-hello-
$ singularity pull --name hello.simg shub://vsoch/hello-world
˓→name
1.3. Download pre-built images
# pull with custom
3
Singularity Container Documentation, Release 2.6
Singularity images can also be pulled and named by an associated GitHub commit or content hash. You can also use
pull with the docker:// uri to reference Docker images served from a registry. In this case pull does not just
download an image file. Docker images are stored in layers, so pull must also combine those layers into a usable
Singularity file.
$ singularity pull docker://godlovedc/lolcow
# with default name
$ singularity pull --name funny.simg docker://godlovedc/lolcow # with custom name
Pulling Docker images reduces reproducibility. If you were to pull a Docker image today and then wait six months
and pull again, you are not guaranteed to get the same image. If any of the source layers has changed the image will
be altered. If reproducibility is a priority for you, try building your images from Singularity Hub. You can also use
the build command to download pre-built images from an external resource. When using build you must specify
a name for your container like so:
$ singularity build hello-world.simg shub://vsoch/hello-world
$ singularity build lolcow.simg docker://godlovedc/lolcow
Unlike pull, build will convert your image to the latest Singularity image format after downloading it.
build is like a “Swiss Army knife” for container creation. In addition to downloading images, you can use build
to create images from other images or from scratch using a recipe file . You can also use build
to convert an image between the 3 major container formats supported by Singularity. We discuss those image formats
below in the Build images from scratch section.
1.4 Interact with images
Once you have an image, you can interact with it in several ways. For these examples we will use a hello-world.
simg image that can be downloaded from Singularity Hub like so.
$ singularity pull --name hello-world.simg shub://vsoch/hello-world
1.4.1 Shell
The shell command allows you to spawn a new shell within your container and interact with it as though it were a
small virtual machine.
$ singularity shell hello-world.simg
Singularity: Invoking an interactive shell within container...
# I am the same user inside as outside!
Singularity hello-world.simg:~/Desktop> whoami
vanessa
Singularity hello-world.simg:~/Desktop> id
uid=1000(vanessa) gid=1000(vanessa) groups=1000(vanessa),4(adm),24,27,30(tape),46,113,
˓→128,999(input)
4
Chapter 1. Quick Start
Singularity Container Documentation, Release 2.6
shell also works with the shub:// and docker:// URIs. This creates an ephemeral container that disappears
when the shell is exited.
$ singularity shell shub://vsoch/hello-world
1.4.2 Executing Commands
The exec command allows you to execute a custom command within a container by specifying the image file. For
instance, to list the root (/) of our hello-world.simg image, we could do the following:
$ singularity exec hello-world.simg ls /
anaconda-post.log
etc
lib64
mnt
root
singularity
bin
home
lost+found
opt
run
srv
usr
dev
lib
media
proc
sbin
sys
var
tmp
exec also works with the shub:// and docker:// URIs. This creates an ephemeral container that executes a
command and disappears.
$ singularity exec shub://singularityhub/ubuntu cat /etc/os-release
1.4.3 Running a container
Singularity containers contain runscripts. These are user defined scripts that define the actions a container should
perform when someone runs it. The runscript can be triggered with the run command, or simply by calling the
container as though it were an executable.
$ singularity run hello-world.simg
$ ./hello-world.simg
run also works with shub:// and docker:// URIs. This creates an ephemeral container that runs and then
disappears.
$ singularity run shub://GodloveD/lolcow
1.4.4 Working with Files
Files on the host are reachable from within the container.
$ echo "Hello World" > $HOME/hello-kitty.txt
$ singularity exec vsoch-hello-world-master.simg cat $HOME/hello-kitty.txt
Hello World
This example works because hello-kitty.txt exists in the user’s home directory. By default singularity bind
mounts /home/$USER, /tmp, and $PWD into your container at runtime. You can specify additional directories to
bind mount into your container with the - -bind option. In this example, the data directory on the host system is bind
mounted to the /mnt directory inside the container.
1.4. Interact with images
5
Singularity Container Documentation, Release 2.6
$ echo "I am your father" >/data/vader.sez
$ ~/sing-dev/bin/singularity exec --bind /data:/mnt hello-world.simg cat /mnt/vader.
˓→sez
I am your father
1.5 Build images from scratch
As of Singularity v2.4 by default build produces immutable images in the squashfs file format. This ensures reproducible and verifiable images. However, during testing and debugging you may want an image format that is writable.
This way you can shell into the image and install software and dependencies until you are satisfied that your container will fulfill your needs. For these scenarios, Singularity supports two other image formats: a sandbox format
(which is really just a chroot directory), and a writable format (the ext3 file system that was used in Singularity
versions less than 2.4).
For more details about the different build options and best practices, read about the singularity flow.
1.5.1 Sandbox Directory
To build into a sandbox (container in a directory) use the build --sandbox command and option:
$ sudo singularity build --sandbox ubuntu/ docker://ubuntu
This command creates a directory called ubuntu/ with an entire Ubuntu Operating System and some Singularity
metadata in your current working directory. You can use commands like shell, exec , and run with this directory
just as you would with a Singularity image. You can also write files to this directory from within a Singularity session
(provided you have the permissions to do so). These files will be ephemeral and will disappear when the container is
finished executing. However if you use the --writable option the changes will be saved into your directory so that
you can use them the next time you use your container.
1.5.2 Writable Image
If you prefer to have a writable image file, you can build a container with the --writable option.
$ sudo singularity build --writable ubuntu.img docker://ubuntu
This produces an image that is writable with an ext3 file system. Unlike the sandbox, it is a single image file. Also
by convention this file name has an “.img” extension instead of “.simg” . When you want to alter your image, you
can use commands like shell, exec, run, with the --writable option. Because of permission issues it may be
necessary to execute the container as root to modify it.
$ sudo singularity shell --writable ubuntu.img
1.5.3 Converting images from one format to another
The build command allows you to build a container from an existing container. This means that you can use it to
convert a container from one format to another. For instance, if you have already created a sandbox (directory) and
want to convert it to the default immutable image format (squashfs) you can do so:
6
Chapter 1. Quick Start
Singularity Container Documentation, Release 2.6
$ singularity build new-squashfs sandbox
Doing so may break reproducibility if you have altered your sandbox outside of the context of a recipe file, so you are
advised to exercise care. You can use build to convert containers to and from writable, sandbox, and default
(squashfs) file formats via any of the six possible combinations.
1.5.4 Singularity Recipes
For a reproducible, production-quality container, we recommend that you build a container with the default (squashfs)
file format using a Singularity recipe file. This also makes it easy to add files, environment variables, and install
custom software, and still start from your base of choice (e.g., Singularity Hub). A recipe file has a header and a body.
The header determines what kind of base container to begin with, and the body is further divided into sections (called
scriptlets) that do things like install software, setup the environment, and copy files into the container from the host
system. Here is an example of a recipe file:
Bootstrap: shub
From: singularityhub/ubuntu
%runscript
exec echo "The runscript is the containers default runtime command!"
%files
/home/vanessa/Desktop/hello-kitty.txt
# copied to root of container
/home/vanessa/Desktop/party_dinosaur.gif
/opt/the-party-dino.gif #
%environment
VARIABLE=MEATBALLVALUE
export VARIABLE
%labels
AUTHOR vsochat@stanford.edu
%post
apt-get update && apt-get -y install python3 git wget
mkdir /data
echo "The post section is where you can install, and configure your container."
To build a container from this definition file (assuming it is a file named Singularity), you would call build like so:
$ sudo singularity build ubuntu.simg Singularity
1.5. Build images from scratch
7
Singularity Container Documentation, Release 2.6
In this example, the header tells singularity to use a base Ubuntu image from Singularity Hub. The %runscript
section defines actions for the container to take when it is executed (in this case a simple message). The %files
section copies some files into the container from the host system at build time. The %environment section defines
some environment variables that will be available to the container at runtime. The %labels section allows for custom
metadata to be added to the container. And finally the %post section executes within the container at build time after
the base OS has been installed. The %post section is therefore the place to perform installations of custom apps.
This is a very small example of the things that you can do with a recipe file . In addition to building a container from
Singularity Hub, you can start with base images from Docker Hub, use images directly from official repositories such
as Ubuntu, Debian, CentOS, Arch, and BusyBox, use an existing container on your host system as a base, or even
take a snapshot of the host system itself and use that as a base image. If you want to build Singularity images without
having singularity installed in a build environment, you can build images using Singularity Hub instead. If you want a
more detailed rundown and examples for different build options, see our singularity flow page.
8
Chapter 1. Quick Start
CHAPTER
TWO
INTRODUCTION
This document will introduce you to Singularity, If you are viewing this on the web there should be links in the bar
to the left that will direct you to other important topics. If you want to get a quick overview, see our quickstart. If
you want to understand which commands are a best fit for your use case, see our build flow section. There is also a
separate Singularity Administration Guide that targets system administrators, so if you are a service provider, or an
interested user, it is encouraged that you read that document as well.
2.1 Welcome to Singularity!
Singularity is a container solution created by necessity for scientific and application driven workloads. Over the
past decade and a half, virtualization has gone from an engineering toy to a global infrastructure necessity and the
evolution of enabling technologies has flourished. Most recently, we have seen the introduction of the latest spin on
virtualization. . . “containers”. People tend to view containers in light of their virtual machine ancestry and these
preconceptions influence feature sets and expected use cases. This is both a good and a bad thing. . . For industry
and enterprise-centric container technologies this is a good thing. Web enabled cloud requirements are very much
in alignment with the feature set of virtual machines, and thus the preceding container technologies. But the idea of
containers as miniature virtual machines is a bad thing for the scientific world and specifically the high performance
computation (HPC) community. While there are many overlapping requirements in these two fields, they differ in
ways that make a shared implementation generally incompatible. Some groups have leveraged custom-built resources
that can operate on a lower performance scale, but proper integration is difficult and perhaps impossible with today’s
technology. Many scientists could benefit greatly by using container technology, but they need a feature set that differs
somewhat from that available with current container technology. This necessity drives the creation of Singularity and
articulated its four primary functions:
2.1.1 Mobility of Compute
Mobility of compute is defined as the ability to define, create and maintain a workflow and be confident that the workflow can be executed on different hosts, operating systems (as long as it is Linux) and service providers. Being able to
contain the entire software stack, from data files to library stack, and portably move it from system to system means
true mobility. Singularity achieves this by utilizing a distributable image format that contains the entire container and
stack into a single file. This file can be copied, shared, archived, and standard UNIX file permissions also apply. Additionally containers are portable (even across different C library versions and implementations) which makes sharing
and copying an image as easy as cp or scp or ftp.
2.1.2 Reproducibility
As mentioned above, Singularity containers utilize a single file which is the complete representation of all the files
within the container. The same features which facilitate mobility also facilitate reproducibility. Once a contained
9
Singularity Container Documentation, Release 2.6
workflow has been defined, a snapshot image can be taken of a container. The image can be then archived and locked
down such that it can be used later and you can be confident that the code within the container has not changed.
2.1.3 User Freedom
System integrators, administrators, and engineers spend a lot of effort maintaining their systems, and tend to take a
cautious approach. As a result, it is common to see hosts installed with production, mission critical operating systems
that are “old” and have few installed packages. Users may find software or libraries that are too old or incompatible
with the software they must run, or the environment may just lack the software stack they need due to complexities
with building, specific software knowledge, incompatibilities or conflicts with other installed programs.
Singularity can give the user the freedom they need to install the applications, versions, and dependencies for their
workflows without impacting the system in any way. Users can define their own working environment and literally
copy that environment image (single file) to a shared resource, and run their workflow inside that image.
2.1.4 Support on Existing Traditional HPC
Replicating a virtual machine cloud like environment within an existing HPC resource is not a reasonable goal for
many administrators. There are a lots of container systems available which are designed for enterprise, as a replacement for virtual machines, are cloud focused, or require unstable or unavailable kernel features. Singularity supports
existing and traditional HPC resources as easily as installing a single package onto the host operating system. Custom
configurations may be achieved via a single configuration file, and the defaults are tuned to be generally applicable
for shared environments. Singularity can run on host Linux distributions from RHEL6 (RHEL5 for versions lower
than 2.2) and similar vintages, and the contained images have been tested as far back as Linux 2.2 (approximately 14
years old). Singularity natively supports InfiniBand, Lustre, and works seamlessly with all resource managers (e.g.
SLURM, Torque, SGE, etc.) because it works like running any other command on the system. It also has built-in
support for MPI and for containers that need to leverage GPU resources.
2.2 A High Level View of Singularity
2.2.1 Security and privilege escalation
A user inside a Singularity container is the same user as outside the container This is one of Singularities defining
characteristics. It allows a user (that may already have shell access to a particular host) to simply run a command
inside of a container image as themselves. The following example scenario will help illustrate a Singularity container:
%SERVER and %CLUSTER are large expensive systems with resources far exceeding those of my personal workstation. But because they are shared systems, no users have root access. The environments are tightly controlled and
managed by a staff of system administrators. To keep these systems secure, only the system administrators are granted
root access and they control the state of the operating systems and installed applications. If a user is able to escalate
to root (even within a container) on %SERVER or %CLUSTER, they can do bad things to the network, cause denial
of service to the host (as well as other hosts on the same network), and may have unrestricted access to file systems
reachable by the container.
To mitigate security concerns like this, Singularity limits one’s ability to escalate permission inside a container. For
example, if I do not have root access on the target system, I should not be able to escalate my privileges within the
container to root either. This is semi-antagonistic to Singularity’s 3rd tenant; allowing the users to have freedom of
their own environments. Because if a user has the freedom to create and manipulate their own container environment,
surely they know how to escalate their privileges to root within that container. Possible means to escalation could
include setting the root user’s password, or enabling themselves to have sudo access. For these reasons, Singularity
prevents user context escalation within the container, and thus makes it possible to run user supplied containers on
shared infrastructures. This mitigation dictates the Singularity workflow. If a user needs to be root in order to make
10
Chapter 2. Introduction
Singularity Container Documentation, Release 2.6
changes to their containers, then they need to have an endpoint (a local workstation, laptop, or server) where they
have root access. Considering almost everybody at least has a laptop, this is not an unreasonable or unmanageable
mitigation, but it must be defined and articulated.
2.2.2 The Singularity container image
Singularity makes use of a container image file, which physically includes the container. This file is a physical
representation of the container environment itself. If you obtain an interactive shell within a Singularity container, you
are literally running within that file. This design simplifies management of files to the element of least surprise, basic
file permission. If you either own a container image, or have read access to that container image, you can start a shell
inside that image. If you wish to disable or limit access to a shared image, you simply change the permission ACLs to
that file. There are numerous benefits for using a single file image for the entire container:
• Copying or branching an entire container is as simple as cp
• Permission/access to the container is managed via standard file system permissions
• Large scale performance (especially over parallel file systems) is very efficient
• No caching of the image contents to run (especially nice on clusters)
• Containers are compressed and consume very little disk space
• Images can serve as stand-alone programs, and can be executed like any other program on the host
2.2.2.1 Copying, sharing, branching, and distributing your image
A primary goal of Singularity is mobility. The single file image format makes mobility easy. Because Singularity
images are single files, they are easily copied and managed. You can copy the image to create a branch, share the
image and distribute the image as easily as copying any other file you control!
If you want an automated solution for building and hosting your image, you can use our container registry Singularity
Hub. Singularity Hub can automatically build Singularity recipe files from a GitHub repository each time that you
push. It provides a simple cloud solution for storing and sharing your image. If you want to host your own Registry,
then you should check out Singularity Registry. If you have ideas or suggestions for how Singularity can better support
reproducible science, please reach out!.
2.2.2.2 Supported container formats
• squashfs: the default container format is a compressed read-only file system that is widely used for things like
live CDs/USBs and cell phone OS’s
• ext3: (also called writable) a writable image file containing an ext3 file system that was the default container
format prior to Singularity version 2.4
• directory: (also called sandbox) standard Unix directory containing a root container image
• tar.gz: zlib compressed tar archive
• tar.bz2: bzip2 compressed tar archive
• tar: uncompressed tar archive
2.2.2.3 Supported Uniform Resource Identifiers (URI)
Singularity also supports several different mechanisms for obtaining the images using a standard URI format.
2.2. A High Level View of Singularity
11
Singularity Container Documentation, Release 2.6
• shub:// Singularity Hub is our own registry for Singularity containers. If you want to publish a container, or give
easy access to others from their command line, or enable automatic builds, you should build it on Singularity
Hub.
• docker:// Singularity can pull Docker images from a Docker registry, and will run them non-persistently (e.g.
changes are not persisted as they can not be saved upstream). Note that pulling a Docker image implies assembling layers at runtime, and two subsequent pulls are not guaranteed to produce an identical image.
• instance:// A Singularity container running as service, called an instance, can be referenced with this URI.
2.2.3 Name-spaces and isolation
When asked, “What namespaces does Singularity virtualize?”, the most appropriate response from a Singularity point
of view is “As few as possible!”. This is because the goals of Singularity are mobility, reproducibility and freedom,
not full isolation (as you would expect from industry driven container technologies). Singularity only separates the
needed namespaces in order to satisfy our primary goals.
Coupling incomplete isolation with the fact that a user inside a container is the same user outside the container, allows
Singularity to blur the lines between a container and the underlying host system. Using Singularity feels like running in
a parallel universe, where there are two time lines. In one time line, the system administrators installed their operating
system of choice. But on an alternate time line, we bribed the system administrators and they installed our favorite
operating system and apps, and gave us full control but configured the rest of the system identically. And Singularity
gives us the power to pick between these two time lines. In other words, Singularity allows you to virtually swap out
the underlying operating system for one that you’ve defined without affecting anything else on the system and still
having all of the host resources available to you.
The container is similar to logging into another identical host running a different operating system. e.g. One moment
you are on Centos-6 and the next minute you are on the latest version of Ubuntu that has Tensorflow installed, or
Debian with the latest OpenFoam, or a custom workflow that you installed. But you are still the same user with
the same files running the same PIDs. Additionally, the selection of name-space virtualization can be dynamic or
conditional. For example, the PID namespace is not separated from the host by default, but if you want to separate it,
you can with a command line (or environment variable) setting. You can also decide if you want to contain a process
so it can not reach out to the host file system if you don’t know if you trust the image. But by default, you are allowed
to interface with all of the resources, devices and network inside the container as you are outside the container (given
your level of permissions).
2.2.4 Compatibility with standard work-flows, pipes and IO
Singularity abstracts the complications of running an application in an environment that differs from the host. For
example, applications or scripts within a Singularity container can easily be part of a pipeline that is being executed
on the host. Singularity containers can also be executed from a batch script or other program (e.g. an HPC system’s
resource manager) natively. Some usage examples of Singularity can be seen as follows:
$ singularity exec dummy.img xterm
# run xterm from within the container
$ singularity exec dummy.img python script.py
˓→using container's python
# run a script on the host system
$ singularity exec dummy.img python < /path/to/python/script.py
˓→redirection
# do the same via
$ cat /path/to/python/script.py | singularity exec dummy.img python
˓→via a pipe
# do the same
You can even run MPI executables within the container as simply as:
12
Chapter 2. Introduction
Singularity Container Documentation, Release 2.6
$ mpirun -np X singularity exec /path/to/container.img /usr/bin/mpi_program_inside_
˓→container (mpi program args)
2.2.5 The Singularity Process Flow
When executing container commands, the Singularity process flow can be generalized as follows:
1. Singularity application is invoked
2. Global options are parsed and activated
3. The Singularity command (subcommand) process is activated
4. Subcommand options are parsed
5. The appropriate sanity checks are made
6. Environment variables are set
7. The Singularity Execution binary is called (sexec)
8. Sexec determines if it is running privileged and calls the SUID code if necessary
9. Namespaces are created depending on configuration and process requirements
10. The Singularity image is checked, parsed, and mounted in the namespace
11. Bind mount points are setup so that files on the host are visible in the CLONE_NEWNS container
12. The namespace CLONE_FS is used to virtualize a new root file system
13. Singularity calls execvp() and Singularity process itself is replaced by the process inside the container
14. When the process inside the container exits, all namespaces collapse with that process, leaving a clean system
All of the above steps are fast and seem instantaneous to the user (i.e. there is little run-time overhead), when measured
on a standard server the overhead was approximately 15-25 thousandths of a second).
2.3 The Singularity Usage Workflow
The security model of Singularity (as described above, “A user inside a Singularity container is the same user as outside the container”) defines the Singularity workflow. There are generally two groups of actions you must implement
on a container; management (building your container) and usage.
In many circumstances building containers require root administrative privileges just like these actions would require
on any system, container, or virtual machine. This means that a user must have access to a system on which they have
root privileges. This could be a server, workstation, a laptop, virtual machine, or even a cloud instance. If you are
using OS X or Windows on your laptop, it is recommended to setup Vagrant, and run Singularity from there (there are
recipes for this which can be found at the Singularity website. Once you have Singularity installed on your endpoint
of choice, this is where you will do the bulk of your container development. This workflow can be described visually
as follows:
On the left side, you have your build environment: a laptop, workstation, or a server that you control. Here you will
(optionally):
1. develop and test containers using --sandbox (build into a writable directory) or --writable (build into a
writable ext3 image)
2. build your production containers with a squashfs filesystem.
2.3. The Singularity Usage Workflow
13
Singularity Container Documentation, Release 2.6
Fig. 1: Singularity workflow
Once you have the container with the necessary applications, libraries and data inside it can be easily shared to other
hosts and executed without requiring root access. A production container should be an immutable object, so if you
need to make changes to your container you should go back to your build system with root privileges, rebuild the
container with the necessary changes, and then re-upload the container to the production system where you wish to
run it.
2.3.1 Singularity Commands
How do the commands work?
The following is a list of the Singularity commands, Click on each command for more information.
• build : Build a container on your user endpoint or build environment
• exec : Execute a command to your container
• inspect : See labels, run and test scripts, and environment variables
• pull : pull an image from Docker or Singularity Hub
• run : Run your image as an executable
• shell : Shell into your image
Image Commands
• image.import : import layers or other file content to your image
• image.export : export the contents of the image to tar or stream
• image.create : create a new image, using the old ext3 filesystem
• image.expand : increase the size of your image (old ext3)
Instance Commands
Instances were added in 2.4. This list is brief, and likely to expand with further development.
• instances : Start, stop, and list container instances
Deprecated Commands The following commands are deprecated in 2.4 and will be removed in future releases.
14
Chapter 2. Introduction
Singularity Container Documentation, Release 2.6
• bootstrap : Bootstrap a container recipe
2.4 Support
Have a question, or need further information? Reach out to us.
2.5 About
2.5.1 Overview
While there are many container solutions being used commonly in this day and age, what makes Singularity different
stems from it’s primary design features and thus it’s architecture:
1. Reproducible software stacks: These must be easily verifiable via checksum or cryptographic signature in
such a manner that does not change formats (e.g. splatting a tarball out to disk). By default Singularity uses a
container image file which can be checksummed, signed, and thus easily verified and/or validated.
2. Mobility of compute: Singularity must be able to transfer (and store) containers in a manner that works with
standard data mobility tools (rsync, scp, gridftp, http, NFS, etc..) and maintain software and data controls
compliancy (e.g. HIPAA, nuclear, export, classified, etc..)
3. Compatibility with complicated architectures: The runtime must be immediately compatible with existing
HPC, scientific, compute farm and even enterprise architectures any of which maybe running legacy kernel
versions (including RHEL6 vintage systems) which do not support advanced namespace features (e.g. the user
namespace)
4. Security model: Unlike many other container systems designed to support trusted users running trusted containers we must support the opposite model of untrusted users running untrusted containers. This changes the
security paradigm considerably and increases the breadth of use cases we can support.
2.5.2 Background
A Unix operating system is broken into two primary components, the kernel space, and the user space. The Kernel
supports the user space by interfacing with the hardware, providing core system features and creating the software
compatibility layers for the user space. The user space on the other hand is the environment that most people are most
familiar with interfacing with. It is where applications, libraries and system services run.
Containers are shifting the emphasis away from the runtime environment by commoditizing the user space into swappable components. This means that the entire user space portion of a Linux operating system, including programs,
custom configurations, and environment can be interchanged at runtime. Singularity emphasis and simplifies the
distribution vector of containers to be that of a single, verifiable file.
Software developers can now build their stack onto whatever operating system base fits their needs best, and create
distributable runtime encapsulated environments and the users never have to worry about dependencies, requirements,
or anything else from the user space.
Singularity provides the functionality of a virtual machine, without the heavyweight implementation and performance
costs of emulation and redundancy!
2.5.2.1 The Singularity Solution
Singularity has two primary roles:
2.4. Support
15
Singularity Container Documentation, Release 2.6
1. Container Image Generator: Singularity supports building different container image formats from scratch
using your choice of Linux distribution bases or leveraging other container formats (e.g. Docker Hub). Container
formats supported are the default compressed immutable (read only) image files, writable raw file system based
images, and sandboxes (chroot style directories).
2. Container Runtime: The Singularity runtime is designed to leverage the above mentioned container formats
and support the concept of untrusted users running untrusted containers. This counters the typical container
runtime practice of trusted users running trusted containers and as a result of that, Singularity utilizes a very
different security paradigm. This is a required feature for implementation within any multi-user environment.
The Singularity containers themselves are purpose built and can include a simple application and library stack or a
complicated work flow that can interface with the hosts resources directly or run isolated from the host and other
containers. You can even launch a contained work flow by executing the image file directly! For example, assuming
that ~/bin is in the user’s path as it is normally by default:
$ mkdir ~/bin
$ singularity build ~/bin/python-latest docker://python:latest
Docker image path: index.docker.io/library/python:latest
Cache folder set to /home/gmk/.singularity/docker
Importing: base Singularity environment
Importing: /home/gmk/.singularity/docker/
˓→sha256:aa18ad1a0d334d80981104c599fa8cef9264552a265b1197af11274beba767cf.tar.gz
Importing: /home/gmk/.singularity/docker/
˓→sha256:15a33158a1367c7c4103c89ae66e8f4fdec4ada6a39d4648cf254b32296d6668.tar.gz
Importing: /home/gmk/.singularity/docker/
˓→sha256:f67323742a64d3540e24632f6d77dfb02e72301c00d1e9a3c28e0ef15478fff9.tar.gz
Importing: /home/gmk/.singularity/docker/
˓→sha256:c4b45e832c38de44fbab83d5fcf9cbf66d069a51e6462d89ccc050051f25926d.tar.gz
Importing: /home/gmk/.singularity/docker/
˓→sha256:b71152c33fd217d4408c0e7a2f308e66c0be1a58f4af9069be66b8e97f7534d2.tar.gz
Importing: /home/gmk/.singularity/docker/
˓→sha256:c3eac66dc8f6ae3983a7f37e3da84a8acb828faf909be2d6649e9d7c9caffc28.tar.gz
Importing: /home/gmk/.singularity/docker/
˓→sha256:494ffdf1660cdec946ae13d6b726debbcec4c393a7eecfabe97caf3961f62c36.tar.gz
Importing: /home/gmk/.singularity/docker/
˓→sha256:f5ec737c23de3b1ae2b1ce3dce1fd20e0cb246e4c73584dcd4f9d2f50063324e.tar.gz
Importing: /home/gmk/.singularity/metadata/
˓→sha256:5dd22488ce22f06bed1042cc03d3efa5a7d68f2a7b3dcad559df4520154ef9c2.tar.gz
WARNING: Building container as an unprivileged user. If you run this container as root
WARNING: it may be missing some functionality.
Building Singularity image...
(continues on next page)
16
Chapter 2. Introduction
Singularity Container Documentation, Release 2.6
(continued from previous page)
Cleaning up...
Singularity container built: /home/gmk/bin/python-latest
$ which python-latest
/home/gmk/bin/python-latest
$ python-latest --version
Python 3.6.3
$ singularity exec ~/bin/python-latest cat /etc/debian_version
8.9
$ singularity shell ~/bin/python-latest
Singularity: Invoking an interactive shell within container...
Singularity python-latest:~>
Additionally, Singularity blocks privilege escalation within the container and you are always yourself within a container! If you want to be root inside the container, you first must be root outside the container. This simple usage
paradigm mitigates many of the security concerns that exists with containers on multi-user shared resources. You
can directly call programs inside the container from outside the container fully incorporating pipes, standard IO, file
system access, X11, and MPI. Singularity images can be seamlessly incorporated into your environment.
2.5.2.2 Portability and Reproducibility
Singularity containers are designed to be as portable as possible, spanning many flavors and vintages of Linux. The
only known limitation is binary compatibility of the kernel and container. Singularity has been ported to distributions going as far back as RHEL 5 (and compatibles) and works on all currently living versions of RHEL, Debian,
Arch, Alpine, Gentoo and Slackware. Within the container, there are almost no limitations aside from basic binary
compatibility.
Inside the container, it is also possible to have a very old version of Linux supported. The oldest known version of
Linux tested was a Red Hat Linux 8 container, that was converted by hand from a physical computer’s hard drive as the
15 year old hardware was failing. The container was transferred to a new installation of Centos7, and is still running
in production!
Each Singularity image includes all of the application’s necessary run-time libraries and can even include the required
data and files for a particular application to run. This encapsulation of the entire user-space environment facilitates not
only portability but also reproducibility.
2.5. About
17
Singularity Container Documentation, Release 2.6
2.5.3 Features
2.5.3.1 Encapsulation of the environment
Mobility of Compute is the encapsulation of an environment in such a manner to make it portable between systems.
This operating system environment can contain the necessary applications for a particular work-flow, development
tools, and/or raw data. Once this environment has been developed it can be easily copied and run from any other
Linux system.
This allows users to BYOE (Bring Their Own Environment) and work within that environment anywhere that Singularity is installed. From a service provider’s perspective we can easily allow users the flexibility of “cloud”-like
environments enabling custom requirements and workflows.
Additionally there is always a misalignment between development and production environments. The service provider
can only offer a stable, secure tuned production environment which in many times will not keep up with the fast paced
requirements of developers. With Singularity, you can control your own development environment and simply copy
them to the production resources.
2.5.3.2 Containers are image based
Using image files have several key benefits:
First, this image serves as a vector for mobility while retaining permissions of the files within the image. For example,
a user may own the image file so they can copy the image to and from system to system. But, files within an image must
be owned by the appropriate user. For example, ‘/etc/passwd’ and ‘/’ must be owned by root to achieve appropriate
access permission. These permissions are maintained within a user owned image.
There is never a need to build, rebuild, or cache an image! All IO happens on an as needed basis. The overhead in
starting a container is in the thousandths of a second because there is never a need to pull, build or cache anything!
On HPC systems a single image file optimizes the benefits of a shared parallel file system! There is a single metadata
lookup for the image itself, and the subsequent IO is all directed to the storage servers themselves. Compare this to the
massive amount of metadata IO that would be required if the container’s root file system was in a directory structure. It
is not uncommon for large Python jobs to DDOS (distributed denial of service) a parallel meta-data server for minutes!
The Singularity image mitigates this considerably.
2.5.3.3 No user contextual changes or root escalation allowed
When Singularity is executed, the calling user is maintained within the container. For example, if user ‘gmk’ starts a
Singularity container, the same user ‘gmk’ will end up within the container. If ‘root’ starts the container, ‘root’ will be
the user inside the container.
Singularity also limits a user’s ability to escalate privileges within the container. Even if the user works in their own
environment where they configured ‘sudo’ or even removed root’s password, they will not be able to ‘sudo’ or ‘su’ to
root. If you want to be root inside the container, you must first be root outside the container.
Because of this model, it becomes possible to blur the line of access between what is contained and what is on the host
as Singularity does not grant the user any more access than they already have. It also enables the implementation on
shared/multi-tenant resources.
2.5.3.4 No root owned daemon processes
Singularity does not utilize a daemon process to manage the containers. While daemon processes do facilitate certain
types of workflows and privilege escalation, it breaks all resource controlled environments. This is because a user’s
18
Chapter 2. Introduction
Singularity Container Documentation, Release 2.6
job becomes a subprocess of the daemon (rather than the user’s shell) and the daemon process is outside of the reach
of a resource manager or batch scheduler.
Additionally, securing a root owned daemon process which is designed to manipulate the host’s environment becomes
tricky. In currently implemented models, it is possible to grant permissions to users to control the daemon, or not.
There is no sense of ACL’s or access of what users can and can not do.
While there are some other container implementations that do not leverage a daemon, they lack other features necessary
to be considered as reasonable user facing solution without having root access. For example, there has been a standing
unimplemented patch to RunC (already daemon-less) which allows for root-less usage (no root). But, user contexts
are not maintained, and it will only work with chroot directories (instead of an image) where files must be owned and
manipulated by the root user!
2.5.4 Use Cases
2.5.4.1 BYOE: Bring Your Own Environment
Engineering work-flows for research computing can be a complicated and iterative process, and even more so on a
shared and somewhat inflexible production environment. Singularity solves this problem by making the environment
flexible.
Additionally, it is common (especially in education) for schools to provide a standardized pre-configured Linux distribution to the students which includes all of the necessary tools, programs, and configurations so they can immediately
follow along.
2.5.4.2 Reproducible science
Singularity containers can be built to include all of the programs, libraries, data and scripts such that an entire demonstration can be contained and either archived or distributed for others to replicate no matter what version of Linux they
are presently running.
Commercially supported code requiring a particular environment Some commercial applications are only certified to
run on particular versions of Linux. If that application was installed into a Singularity container running the version
of Linux that it is certified for, that container could run on any Linux host. The application environment, libraries, and
certified stack would all continue to run exactly as it is intended.
Additionally, Singularity blurs the line between container and host such that your home directory (and other directories) exist within the container. Applications within the container have full and direct access to all files you own thus
you can easily incorporate the contained commercial application into your work and process flow on the host.
2.5.4.3 Static environments (software appliances)
Fund once, update never software development model. While this is not ideal, it is a common scenario for research
funding. A certain amount of money is granted for initial development, and once that has been done the interns, grad
students, post-docs, or developers are reassigned to other projects. This leaves the software stack un-maintained, and
even rebuilds for updated compilers or Linux distributions can not be done without unfunded effort.
2.5.4.4 Legacy code on old operating systems
Similar to the above example, while this is less than ideal it is a fact of the research ecosystem. As an example, I know
of one Linux distribution which has been end of life for 15 years which is still in production due to the software stack
which is custom built for this environment. Singularity has no problem running that operating system and application
stack on a current operating system and hardware.
2.5. About
19
Singularity Container Documentation, Release 2.6
2.5.4.5 Complicated software stacks that are very host specific
There are various software packages which are so complicated that it takes much effort in order to port, update and
qualify to new operating systems or compilers. The atmospheric and weather applications are a good example of this.
Porting them to a contained operating system will prolong the use-fullness of the development effort considerably.
2.5.4.6 Complicated work-flows that require custom installation and/or data
Consolidating a work-flow into a Singularity container simplifies distribution and replication of scientific results.
Making containers available along with published work enables other scientists to build upon (and verify) previous
scientific work.
2.5.5 License
Singularity is released under a standard 3 clause BSD license. Please see our LICENSE file for more details).
2.5.6 Getting started
Jump in and get started, or find ways to get help.
• Project lead: Gregory M. Kurtzer
20
Chapter 2. Introduction
CHAPTER
THREE
INSTALLATION
This document will guide you through the process of installing Singularity from source with the version and location
of your choice.
3.1 Before you begin
If you have an earlier version of Singularity installed, you should remove it before executing the installation commands.
These instructions will build Singularity from source on your system. So you will need to have some development
tools installed. If you run into missing dependencies, try installing them WITH apt-get or yum/rpm as shown
below.
$ sudo apt-get update && \
sudo apt-get install \
python \
dh-autoreconf \
build-essential \
libarchive-dev
$ sudo yum update && \
sudo yum groupinstall 'Development Tools' && \
sudo yum install libarchive-devel
3.2 Install from a tag
The following commands will install a tagged version of the GitHub repo to /usr/local. This will work for pre
3.0 tags.
$ git clone https://github.com/sylabs/singularity.git
$ cd singularity
$ git fetch --all
(continues on next page)
21
Singularity Container Documentation, Release 2.6
(continued from previous page)
$ git tag -l
$ git checkout [TAG]
$ ./autogen.sh
$ ./configure --prefix=/usr/local --sysconfdir=/etc
$ make
$ sudo make install
Singularity will be installed in the /usr/local directory hierarchy by default. And if you specify a custom directory with the --prefix option, all of Singularity’s binaries and the configuration file will be installed within that
directory. This last option can be useful if you want to install multiple versions of Singularity, install Singularity on a
shared system, or if you want to remove Singularity easily after installing it.
If you omit the --sysconfdir option , the configuration file will be installed in /usr/local/etc. If you omit
the --prefix option, Singularity will be installed in the /usr/local directory hierarchy by default. And if you
specify a custom directory with the --prefix option, all of Singularity’s binaries and the configuration file will be
installed within that directory.
3.3 Install a specific release
The following commands will install a specific release from GitHub releases page to /usr/local.
$ VER=2.5.1
$ wget https://github.com/sylabs/singularity/releases/download/$VER/singularity-$VER.
˓→tar.gz
$ tar xvf singularity-$VER.tar.gz
$ cd singularity-$VER
$ ./configure --prefix=/usr/local --sysconfdir=/etc
$ make
$ sudo make install
3.4 Install the development branch
The primary development of Singularity now happens on the master branch. Please see the INSTALL.md file in a
copy of the repository.
3.5 Remove an old version
Let’s say that we installed Singularity to /usr/local. To remove it completely, you need to hit all of the following:
22
Chapter 3. Installation
Singularity Container Documentation, Release 2.6
$ sudo rm -rf /usr/local/libexec/singularity
$ sudo rm -rf /usr/local/etc/singularity
$ sudo rm -rf /usr/local/include/singularity
$ sudo rm -rf /usr/local/lib/singularity
$ sudo rm -rf /usr/local/var/lib/singularity/
$ sudo rm /usr/local/bin/singularity
$ sudo rm /usr/local/bin/run-singularity
$ sudo rm /usr/local/etc/bash_completion.d/singularity
$ sudo rm /usr/local/man/man1/singularity.1
If you modified the system configuration directory, remove the singularity.conf file there as well. If you
installed Singularity in a custom directory, you need only remove that directory to uninstall Singularity. For instance if
you installed singularity with the --prefix=/some/temp/dir option argument pair, you can remove Singularity
like so:
$ sudo rm -rf /some/temp/dir
What should you do next? You can check out the quickstart guide, or learn how to interact with your container via the
shell , exec , or run commands. Or click next below to continue reading.
3.6 Install on Windows
3.6.1 Setup
First, install the following software:
• install Git for Windows
• install VirtualBox for Windows
• install Vagrant for Windows
• install Vagrant Manager for Windows
3.6.2 Singularity Vagrant Box
We are maintaining a set of Vagrant Boxes via Vagrant Cloud, one of Hashicorp many tools that likely you’ve used
and haven’t known it. The current stable version of Singularity is available here:
• sylabs/singularity-2.4
For other versions of Singularity see our Vagrant Cloud repository
Run GitBash. The default home directory will be C:Usersyour_username
mkdir singularity-2.4
cd singularity-2.4
3.6. Install on Windows
23
Singularity Container Documentation, Release 2.6
Note that if you had installed a previous version of the vm (and are using the same folder), you must destroy it first.
In our example we create a new folder. To destroy a previous vm:
vagrant destroy
Then issue the following commands to bring up the Virtual Machine:
vagrant init singularityware/singularity-2.4
vagrant up
vagrant ssh
You are then ready to go with Singularity 2.4!
vagrant@vagrant:~$ which singularity
/usr/local/bin/singularity
vagrant@vagrant:~$ singularity --version
2.4-dist
vagrant@vagrant:~$ sudo singularity build growl-llo-world.simg shub://vsoch/hello˓→world
Cache folder set to /root/.singularity/shub
Progress |===================================| 100.0%
Building from local image: /root/.singularity/shub/vsoch-hello-world-master.simg
Building Singularity image...
Singularity container built: growl-llo-world.simg
Cleaning up...
vagrant@vagrant:~$ ./growl-llo-world.simg
RaawwWWWWWRRRR!!
Note that when you do vagrant up you can also select the provider, if you use vagrant for multiple providers. For
example:
vagrant up --provider virtualbox
although this isn’t entirely necessary if you only have it configured for virtualbox.
3.7 Install on Linux
3.7.1 Installation from Source
You can try the following two options:
24
Chapter 3. Installation
Singularity Container Documentation, Release 2.6
3.7.1.1 Option 1: Download latest stable release
You can always download the latest tarball release from GitHub
For example, here is how to download version 2.5.2 and install:
VERSION=2.5.2
wget https://github.com/sylabs/singularity/releases/download/$VERSION/singularity˓→$VERSION.tar.gz
tar xvf singularity-$VERSION.tar.gz
cd singularity-$VERSION
./configure --prefix=/usr/local
make
sudo make install
Note that when you configure, squashfs-tools is not required, however it is required for full functionality. You
will see this message after the configuration:
mksquashfs from squash-tools is required for full functionality
If you choose not to install squashfs-tools, you will hit an error when you try a pull from Docker Hub, for
example.
3.7.1.2 Option 2: Download the latest development code
To download the most recent development code, you should use Git and do the following:
git clone https://github.com/sylabs/singularity.git
cd singularity
./autogen.sh
./configure --prefix=/usr/local
make
sudo make install
Note: The ‘make install’ is required to be run as root to get a properly installed Singularity implementation. If you
do not run it as root, you will only be able to launch Singularity as root due to permission limitations.
3.7.1.3 Prefix in special characters
If you build Singularity with a non-standard --prefix argument, please be sure to review the admin guide for
details regarding the --localstatedir variable. This is especially important in environments utilizing shared
filesystems.
3.7. Install on Linux
25
Singularity Container Documentation, Release 2.6
3.7.1.4 Updating
To update your Singularity version, you might want to first delete the executables for the old version:
sudo rm -rf /usr/local/libexec/singularity
And then install using one of the methods above.
3.7.2 Debian Ubuntu Package
Singularity is available on Debian (and Ubuntu) systems starting with Debian stretch and the Ubuntu 16.10 yakkety
releases. The package is called singularity-container. For recent releases of singularity and backports for
older Debian and Ubuntu releases, we recommend that you use the NeuroDebian repository.
3.7.2.1 Testing first with Docker
If you want a quick preview of the NeuroDebian mirror, you can do this most easily with the NeuroDebian Docker
image (and if you don’t, skip to the next section). Obviously you should have Docker installed before you do this.
First we run the neurodebian Docker image:
$ docker run -it --rm neurodebian
Then we update the cache (very quietly), and look at the singularity-container policy provided:
$ apt-get update -qqq
$ apt-cache policy singularity-container
singularity-container:
Installed: (none)
Candidate: 2.3-1~nd80+1
Version table:
2.3-1~nd80+1 0
500 http://neuro.debian.net/debian/ jessie/main amd64 Packages
You can continue working in Docker, or go back to your host and install Singularity.
3.7.2.2 Adding the Mirror and installing
You should first enable the NeuroDebian repository following instructions on the NeuroDebian site. This means using
the dropdown menus to find the correct mirror for your operating system and location. For example, after selecting
Ubuntu 16.04 and selecting a mirror in CA, I am instructed to add these lists:
sudo wget -O- http://neuro.debian.net/lists/xenial.us-ca.full | sudo tee /etc/apt/
˓→sources.list.d/neurodebian.sources.list
sudo apt-key adv --recv-keys --keyserver hkp://pool.sks-keyservers.net:80
˓→0xA5D32F012649A5A9
26
Chapter 3. Installation
Singularity Container Documentation, Release 2.6
and then update
sudo apt-get update
then singularity can be installed as follows:
sudo apt-get install -y singularity-container
During the above, if you have a previously installed configuration, you might be asked if you want to define a custom
configuration/init, or just use the default provided by the package, eg:
Configuration file '/etc/singularity/init'
==> File on system created by you or by a script.
==> File also in package provided by package maintainer.
What would you like to do about it ?
Your options are:
Y or I
: install the package maintainer's version
N or O
: keep your currently-installed version
D
: show the differences between the versions
Z
: start a shell to examine the situation
The default action is to keep your current version.
*** init (Y/I/N/O/D/Z) [default=N] ? Y
Configuration file '/etc/singularity/singularity.conf'
==> File on system created by you or by a script.
==> File also in package provided by package maintainer.
What would you like to do about it ?
Your options are:
Y or I
: install the package maintainer's version
N or O
: keep your currently-installed version
D
: show the differences between the versions
Z
: start a shell to examine the situation
The default action is to keep your current version.
*** singularity.conf (Y/I/N/O/D/Z) [default=N] ? Y
And for a user, it’s probably well suited to use the defaults. For a cluster admin, we recommend that you read the
admin docs to get a better understanding of the configuration file options available to you. Remember that you can
always tweak the files at /etc/singularity/singularity.conf and /etc/singularity/init if you
want to make changes.
After this install, you should confirm that 2.3-dist is the version installed:
3.7. Install on Linux
27
Singularity Container Documentation, Release 2.6
$ singularity --version
2.4-dist
Note that if you don’t add the NeuroDebian lists, the version provided will be old (e.g., 2.2.1). If you need a backport
build of the recent release of Singularity on those or older releases of Debian and Ubuntu, you can see all the various
builds and other information here.
3.7.3 Build an RPM from source
Like the above, you can build an RPM of Singularity so it can be more easily managed, upgraded and removed. From
the base Singularity source directory do the following:
./autogen.sh
./configure
make dist
rpmbuild -ta singularity-*.tar.gz
sudo yum install ~/rpmbuild/RPMS/*/singularity-[0-9]*.rpm
Note: If you want to have the RPM install the files to an alternative location, you should define the environment
variable ‘PREFIX’ to suit your needs, and use the following command to build:
PREFIX=/opt/singularity
rpmbuild -ta --define="_prefix $PREFIX" --define "_sysconfdir $PREFIX/etc" --define "_
˓→defaultdocdir $PREFIX/share" singularity-*.tar.gz
When using autogen.sh If you get an error that you have packages missing, for example on Ubuntu 16.04:
./autogen.sh
+libtoolize -c
./autogen.sh: 13: ./autogen.sh: libtoolize: not found
+aclocal
./autogen.sh: 14: ./autogen.sh: aclocal: not found
+autoheader
./autogen.sh: 15: ./autogen.sh: autoheader: not found
+autoconf
./autogen.sh: 16: ./autogen.sh: autoconf: not found
+automake -ca -Wno-portability
./autogen.sh: 17: ./autogen.sh: automake: not found
28
Chapter 3. Installation
Singularity Container Documentation, Release 2.6
then you need to install dependencies:
sudo apt-get install -y build-essential libtool autotools-dev automake autoconf
3.7.4 Build an DEB from source
To build a deb package for Debian/Ubuntu/LinuxMint invoke the following commands:
$ fakeroot dpkg-buildpackage -b -us -uc # sudo will ask for a password to run the
˓→tests
$ sudo dpkg -i ../singularity-container_2.3_amd64.deb
Note that the tests will fail if singularity is not already installed on your system. This is the case when you run this
procedure for the first time. In that case run the following sequence:
$ echo "echo SKIPPING TESTS THEYRE BROKEN" > ./test.sh
$ fakeroot dpkg-buildpackage -nc -b -us -uc # this will continue the previous build
˓→without an initial 'make clean'
3.7.5 Install on your Cluster Resource
In the case that you want Singularity installed on a shared resource, you will need to talk to the administrator of the
resource. Toward this goal, we’ve prepared a helpful guide that you can send to him or her. If you have unanswered
questions, please reach out..
3.8 Install on Mac
This recipe demonstrates how to run Singularity on your Mac via Vagrant and Ubuntu. The recipe requires access
to brew which is a package installation subsystem for OS X. This recipe may take anywhere from 5-20 minutes to
complete.
3.8.1 Setup
First, install brew if you do not have it already.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/
˓→master/install)"
Next, install Vagrant and the necessary bits.
brew cask install virtualbox
brew cask install vagrant
brew cask install vagrant-manager
3.8. Install on Mac
29
Singularity Container Documentation, Release 2.6
3.8.2 Option 1: Singularity Vagrant Box
We are maintaining a set of Vagrant Boxes via Vagrant Cloud, one of Hashicorp many tools that likely you’ve used
and haven’t known it. The current stable version of Singularity is available here:
• singularityware/singularity-2.4
For other versions of Singularity see our Vagrant Cloud repository.
mkdir singularity-vm
cd singularity-vm
Note that if you have installed a previous version of the vm, you can either destroy it first, or create a new directory.
vagrant destroy
Then issue the following commands to bring up the Virtual Machine:
vagrant init singularityware/singularity-2.4
vagrant up
vagrant ssh
You are then ready to go with Singularity 2.4!
vagrant@vagrant:~$ which singularity
/usr/local/bin/singularity
vagrant@vagrant:~$ singularity --version
2.4-dist
vagrant@vagrant:~$ sudo singularity build growl-llo-world.simg shub://vsoch/hello˓→world
Cache folder set to /root/.singularity/shub
Progress |===================================| 100.0%
Building from local image: /root/.singularity/shub/vsoch-hello-world-master.simg
Building Singularity image...
Singularity container built: growl-llo-world.simg
Cleaning up...
vagrant@vagrant:~$ ./growl-llo-world.simg
RaawwWWWWWRRRR!!
Note that when you do vagrant up you can also select the provider, if you use vagrant for multiple providers. For
example:
30
Chapter 3. Installation
Singularity Container Documentation, Release 2.6
vagrant up --provider virtualbox
although this isn’t entirely necessary if you only have it configured for virtualbox.
3.8.3 Option 2: Vagrant Box from Scratch (more advanced alternative)
If you want to get more familiar with how Vagrant and VirtualBox work, you can instead build your own Vagrant Box
from scratch. In this case, we will use the Vagrantfile for bento/ubuntu-16.04, however you could also try any
of the other bento boxes that are equally delicious. As before, you should first make a separate directory for your
Vagrantfile, and then init a base image.
mkdir singularity-2.4
cd singularity-2.4
vagrant init bento/ubuntu-16.04
Next, build and start the vagrant hosted VM, and you will install Singularity by sending the entire install script as a
command (with the -c argument). You could just as easily shell into the box first with vagrant ssh, and then run these
commands on your own. To each bento, his own.
vagrant up --provider virtualbox
# Run the necessary commands within the VM to install Singularity
vagrant ssh -c /bin/sh <2.3 you can add files to the container (added before
%post) using the %files section.
In the above, we see that copying something to $SINGULARITY_ROOTFS during %setup was successful to move
the file into the container, but copying during %post was not. Let’s add a setup to our current container, just writing
a file to the root of the image:
Bootstrap: docker
From: ubuntu
%help
Help me. I'm in the container.
%setup
touch ${SINGULARITY_ROOTFS}/tacos.txt
touch avocados.txt
Importantly, notice that the avocados file isn’t relative to $SINGULARITY_ROOTFS, so we would expect it not to be
in the image. Is tacos there?
$ singularity exec roar.simg ls /
bin
environment
lib
mnt
root
scif
sys
boot
etc
lib64
opt
run
singularity
dev
home
media
proc
sbin
srv
usr
**tacos.txt**
var
tmp
Yes! And avocados.txt isn’t inside the image, but in our present working directory:
$ ls
avocados.txt
roar.simg
Singularity
6.1.2.3 %files
If you want to copy files from your host system into the container, you should do so using the %files section.
Each line is a pair of
Source Exif Data:
File Type : PDF
File Type Extension : pdf
MIME Type : application/pdf
PDF Version : 1.5
Linearized : No
Page Count : 168
Page Mode : UseOutlines
Author : User Docs
Title : Singularity Container Documentation
Subject :
Creator : LaTeX with hyperref package
Producer : pdfTeX-1.40.18
Create Date : 2018:09:20 20:26:58+02:00
Modify Date : 2018:09:20 20:26:58+02:00
Trapped : False
PTEX Fullbanner : This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) kpathsea version 6.2.3