Skip to content

Commit 6d50c35

Browse files
committed
going through user docs from top to bottom
1 parent dee855c commit 6d50c35

6 files changed

Lines changed: 130 additions & 141 deletions

File tree

_data/sidebars/user_docs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ entries:
2323
url: /quickstart
2424
output: web, pdf
2525

26-
- title: Singularity Flow
27-
url: /docs-flow
28-
output: web, pdf
29-
3026
- title: Container Recipes
3127
url: /docs-recipes
3228
output: web, pdf
@@ -35,6 +31,10 @@ entries:
3531
url: /docs-build
3632
output: web, pdf
3733

34+
- title: Singularity Flow
35+
url: /docs-flow
36+
output: web, pdf
37+
3838
- title: Bind Paths and Mounts
3939
url: /docs-mount
4040
output: web, pdf

pages/docs/user-docs/docs-flow.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ title: Singularity Flow
33
sidebar: user_docs
44
permalink: docs-flow
55
folder: docs
6-
toc: true
6+
toc: false
77
---
88

9+
This document describes a suggested "best-practices" workflow for building, running, and managing your containers.
10+
11+
{% include toc.html %}
12+
913
There are generally two ways to get images. You either want to pull an image file as is, or (more likely) build your own custom image. We will start with talking about build, and the many different use cases it affords.
1014

1115

@@ -15,26 +19,28 @@ If you read the [quick start](/quickstart), you probably remember that building
1519
### The Singularity Flow
1620
The diagram below is a visual depiction of how you can use Singularity to build images. The high level idea is that we have two environments:
1721

18-
- a development environment (where you have sudo privileges) to test and build your container
19-
- a production environment where you run your container
22+
- a **build** environment (where you have sudo privileges) to test and build your container
23+
- a **production** environment where you run your container
2024

2125
<a href="/assets/img/diagram/singularity-2.4-flow.png" target="_blank" class="no-after">
2226
<img style="max-width:900px" src="/assets/img/diagram/singularity-2.4-flow.png">
2327
</a>
2428

25-
Singularity production images are immutable. This is a feature added as of Singularity 2.4, and it ensures a higher level of reproducibility and verification of images. To read more about the details, check out the <a href="/build">bulid</a>docs. However, immutability is not so great when you are testing, debugging, or otherwise want to quickly change your image. We will proceed by describing a typical workflow of developing first, building a final image, and using in production.
29+
Singularity production images are immutable. This is a feature added as of Singularity 2.4, and it ensures a higher level of reproducibility and verification of images. To read more about the details, check out the [build](docs-build) docs. However, immutability is not so great when you are testing, debugging, or otherwise want to quickly change your image. We will proceed by describing a typical workflow of developing first, building a final image, and using in production.
2630

2731
### 1. Development Commands
2832
If you want a writable image or folder for developing, you have two options:
2933

30-
1. build into a folder that has writable permissions with sudo
31-
2. build into an ext3 image file, also that has writable permissions with sudo and the `--writable` flag
34+
1. build into a directory that has writable permissions using the `--sandbox` option
35+
2. build into an ext3 image file, that has writable permissions with the `--writable` option
36+
37+
In both cases you will need to execute your container with the `--writable` option at runtime for your changes to be persistant.
3238

3339
#### Sandbox Folder
3440
To build into a folder (we call this a "sandbox") just ask for it:
3541

3642
```
37-
sudo singularity build --sandbox ubuntu/ docker://ubuntu
43+
$ sudo singularity build --sandbox ubuntu/ docker://ubuntu
3844
Docker image path: index.docker.io/library/ubuntu:latest
3945
Cache folder set to /root/.singularity/docker
4046
Importing: base Singularity environment
@@ -51,7 +57,7 @@ Singularity container built: ubuntu/
5157
We now have a folder with the entire ubuntu OS, plus some Singularity metadata, plopped in our present working directory.
5258

5359
```
54-
tree -L 1 ubuntu
60+
$ tree -L 1 ubuntu
5561
ubuntu
5662
├── bin
5763
├── boot
@@ -76,31 +82,30 @@ ubuntu
7682
└── var
7783
```
7884

79-
And you can shell into it just like a normal container. Without sudo, you don't have write permission:
85+
And you can shell into it just like a normal container.
8086

8187
```
82-
singularity shell ubuntu
88+
$ singularity shell ubuntu
8389
Singularity: Invoking an interactive shell within container...
8490
8591
Singularity ubuntu:~/Desktop> touch /hello.txt
8692
touch: cannot touch '/hello.txt': Permission denied
8793
```
88-
89-
With sudo, you do:
94+
You can make changes to the container (assuming you have the proper permissions to do so) but those changes will disappear as soon as you exit. To make your changes persistent across sessions, use the `--writable` option. It's also a good practice to shell into your container as root to ensure you have permissions to write where you like.
9095

9196
```
92-
sudo singularity shell ubuntu
97+
$ sudo singularity shell ubuntu
9398
Singularity: Invoking an interactive shell within container...
9499
95100
Singularity ubuntu:/home/vanessa/Desktop> touch /hello.txt
96101
```
97102

98103
#### Writable Image
99-
If you don't want a folder, you can perform a similar development build and specify the `--writable` command.
104+
If you prefer to work with a writable image file rather than a directory, you can perform a similar development build and specify the `--writable` option.
100105
This will produce an image that is writable with an ext3 file system. Unlike the sandbox, it is a single image file.
101106

102107
```
103-
sudo singularity build --writable ubuntu.img docker://ubuntu
108+
$ sudo singularity build --writable ubuntu.img docker://ubuntu
104109
Docker image path: index.docker.io/library/ubuntu:latest
105110
Cache folder set to /root/.singularity/docker
106111
Importing: base Singularity environment
@@ -120,10 +125,10 @@ Cleaning up...
120125
Singularity container built: ubuntu.img
121126
```
122127

123-
The same is true as the above, you can use any commands like `shell`, `exec`, `run`, and if you want a writable image you must use sudo and the `--writable` flag.
128+
You can use this image with commands like `shell`, `exec`, `run`, and if you want to change the image you must use the `--writable` flag. As before, it's a good idea to issue these commands as root to ensure you have the proper permissions to write.
124129

125130
```
126-
sudo singularity shell --writable ubuntu.img
131+
$ sudo singularity shell --writable ubuntu.img
127132
```
128133

129134
>> Development Tip! When building containers, it often is the case that you will have a lot of
@@ -132,7 +137,7 @@ interactively write the build recipe with one of these writable containers, you
132137
build the production (squashfs) container without worrying that it will error and need to be started again.
133138

134139
### 2. Production Commands
135-
Let's set the scene - we just finished buliding our perfect hello world container. It does a fantastic hello-world analysis, and we have written a paper on it! We now want to build an immutable container - meaning that if someone obtained our container and tried to change it, they could not. They *could* easily use the same recipe that you used (it is provided as metadata inside the container), so your work can still be extended.
140+
Let's set the scene - we just finished buliding our perfect hello world container. It does a fantastic hello-world analysis, and we have written a paper on it! We now want to build an immutable container - meaning that if someone obtained our container and tried to change it, they could not. They *could* easily use the same recipe that you used (it is provided as metadata inside the container), or convert your container to one of the writable formats above using `build`. So your work can still be extended.
136141

137142
#### Recommended Production Build
138143
What we want for production is a build into a <a href="https://en.wikipedia.org/wiki/SquashFS" target="_blank">squashfs image</a>. Squashfs is a read only, and compressed filesystem, and well suited for confident archive and re-use of your hello-world. To build a production image, just remove the extra options:
@@ -152,8 +157,6 @@ Building Singularity image...
152157
Cleaning up...
153158
Singularity container built: ubuntu.simg
154159
```
155-
You will also notice the extension `.simg`. This is the correct extension to designate a Singularity 2.4, production (squashfs) file.
156-
157160
#### Production Build from Sandbox
158161
We understand that it might be wanted to build a Singularity (squashfs) from a previous development image. While we advocate for the first approach, we support this use case. To do this, given our folder called "ubuntu/" we made above:
159162

@@ -163,8 +166,6 @@ sudo singularity build ubuntu.simg ubuntu/
163166
It could be the case that a cluster maintains a "working" base of container folders (with writable) and then builds and provides production containers to its users.
164167

165168

166-
That's it! You probably want to check out [interacting with images](/quickstart#interacting-with-images) to now use your container, sandbox, or new friend.
167-
168169
If you want to go through this entire process without having singularity installed locally, or without leaving your cluster, you can build images using <a href="https://github.com/singularityhub/singularityhub.github.io/wiki" target="_blank">singularity hub.</a>
169170

170171
{% include links.html %}

pages/docs/user-docs/docs-installation.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
---
2-
title: Quick Start
2+
title: Installation
33
sidebar: user_docs
44
permalink: docs-installation
55
folder: docs
6+
toc: false
67
---
78

9+
This document will guide you through the process of installing Singularity from source with the version and location of your choice.
10+
11+
{% include toc.html %}
812

913
## Before you begin
1014
If you have an earlier version of Singularity installed, you should [remove it](#remove-an-old-version) before executing the installation commands.
@@ -63,7 +67,7 @@ $ sudo make install
6367

6468

6569
## Install the development branch
66-
If you want to test a development branch feature the routine above should be tweaked slightly:
70+
If you want to test a development branch the routine above should be tweaked slightly:
6771

6872

6973
```

pages/docs/user-docs/docs-quickstart.md

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ title: Quick Start
33
sidebar: user_docs
44
permalink: quickstart
55
folder: docs
6-
toc: true
6+
toc: false
77
---
88

99
This guide is intended for running Singularity on a computer where you have root (administrative) privileges. But 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.
1010

11-
## Installation Quick Start
11+
{% include toc.html %}
12+
13+
## Installation
1214
There are many ways to [install Singularity](docs-installation) but this quick start guide will only cover one.
1315

1416
```bash
@@ -211,22 +213,12 @@ I am your father
211213
```
212214

213215
## Build images from scratch
214-
215-
The diagram below shows how you can use Singularity to build images and run images. The high level idea is that we have two environments:
216-
217-
- a build environment (where you have root privileges) to test and build your container
218-
- a production environment where you run your container (where you may or may not have root privileges)
219-
220-
<a href="/assets/img/diagram/singularity-2.4-flow.png" target="_blank" class="no-after">
221-
<img style="max-width:900px" src="/assets/img/diagram/singularity-2.4-flow.png">
222-
</a>
223-
224-
In practice, your build system may or may not differ from your production system. If you want more details about the different build options, read about the [singularity flow](/docs-flow).
225-
226216
As of Singularity v2.4 by default `build` produces immutable images in the squashfs file format. This ensures reproducible and verifiable images.
227217

228218
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).
229219

220+
For more details about the different build options and best practices, read about the [singularity flow](/docs-flow).
221+
230222
### Sandbox Directory
231223
To build into a `sandbox` (container in a directory) use the `build --sandbox` command and option:
232224

@@ -252,12 +244,6 @@ When you want to alter your image, you can use commands like `shell`, `exec`, `r
252244
$ sudo singularity shell --writable ubuntu.img
253245
```
254246

255-
>> Development Tip! When building containers, it often is the case that you will have a lot of
256-
testing of installation commands, and if building a production image, one error will stop the entire build. If you
257-
interactively write the build recipe with one of these writable formats, you can debug as you go, and then
258-
build the production (squashfs) container without worrying that it will error and need to be started again.
259-
260-
261247
### Converting images from one format to another
262248
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:
263249

0 commit comments

Comments
 (0)