You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/docs/contributing/contributing-docs.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,12 +3,14 @@ title: Contributing to Documentation
3
3
sidebar: main_sidebar
4
4
permalink: contributing-docs
5
5
folder: releases
6
+
toc: false
6
7
---
7
8
8
9
We (like almost all open source software providers) have a documentation dillemma... We tend to focus on the code features and functionality before working on documentation. And there is very good reason for this, we want to share the love so nobody feels left out!
9
10
10
11
The following documentation page assumes one is running on OS X, but if you are not, you should be able to easily transpose the necessary commands to your operating system of choice.
Make sure to resize your terminal to 25 rows x 115 columns or less before you
119
+
begin your recording. Otherwise it will not display properly on the webpage.
116
120
117
-
Once you've generated an asciicast, you should drop the file (e.g., some `demo-asciicast.js`) into the `assets/asciicast` folder, and then include the following in the page or post:
121
+
Once you've generated an asciicast, you should drop the file (e.g., `demo-asciicast.js`) into the `assets/asciicast` folder, and then include the following in the page or post:
118
122
119
123
```bash
120
124
{{ "{% include asciicast.html source='demo-asciicast.js' title='How to make demos' author='email@domain.com'" }}%}
Copy file name to clipboardExpand all lines: pages/docs/overview/faq.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -213,7 +213,10 @@ See the Singularity on HPC page for more details.
213
213
214
214
### Does Singularity support containers that require GPUs?
215
215
216
-
Yes, Singularity has been tested to run some test and diagnostic code from within a container without modification. There are however potential issues that can come into play when using GPUs, for instance there are version API compatibilities between kernel and user land which will have to be considered.
216
+
Yes. Many users run GPU dependant code within Singularity containers. The
217
+
experimental `--nv` option allows you to leverage host GPUs without installing
218
+
system level drivers into your container. See [the `exec` command](/docs-exec#a-gpu-example) for
Copy file name to clipboardExpand all lines: pages/docs/user-docs/docs-bootstrap-image.md
+20-2Lines changed: 20 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,9 @@ title: Getting Started with Bootstrap
3
3
sidebar: user_docs
4
4
permalink: bootstrap-image
5
5
folder: docs
6
+
toc: false
6
7
---
7
8
8
-
## Bootstrapping a Container
9
9
Bootstrapping is the process where we install an operating system and then configure it appropriately for a specified need. To do this we use a bootstrap definition file (a text file called `Singularity`) which is a recipe of how to specifically build the container. Here we will overview the sections, best practices, and a quick example.
10
10
11
11
{% include toc.html %}
@@ -142,7 +142,25 @@ Version 2.0
142
142
```
143
143
144
144
#### %environment
145
-
Akin to labels, you can add pairs of `VARIABLE` and `VALUE` under environment to be sourced when the container is used as variables in the environment. The entire section is written to a file that gets sourced, so you should generally use the same conventions that you might use in a `bashrc` or `profile`. See <ahref="/docs-environment-metadata">Environment and Metadata</a> for more information about these two sections.
145
+
You can add environment variables to be sourced when the container is used in the `%environment` section. The entire section is written to a file that gets sourced, so you should generally use the same conventions that you might use in a `bashrc` or `profile`.
146
+
147
+
```
148
+
%environment
149
+
export VADER=badguy
150
+
export LUKE=goodguy
151
+
export SOLO=someguy
152
+
```
153
+
154
+
You can also add environment variables to your container in the `%post` section (see below) using the following syntax:
Copy file name to clipboardExpand all lines: pages/docs/user-docs/docs-bootstrap.md
+104-6Lines changed: 104 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,90 @@ toc: false
6
6
folder: docs
7
7
---
8
8
9
+
The process of *bootstrapping* a Singularity container is equivalent to describing a recipe for the container creation. There are several recipe formats that Singularity supports, but only the primary format of version 2.3 will be documented here. If you want a general overview with examples, see <ahref="/bootstrap-image">Bootstrapping an Image</a>. The detailed options for each of the header and sections are provided here.
10
+
9
11
{% include toc.html %}
10
12
11
-
The process of *bootstrapping* a Singularity container is equivalent to describing a recipe for the container creation. There are several recipe formats that Singularity supports, but only the primary format of version 2.3 will be documented here. If you want a general overview with examples, see <ahref="/bootstrap-image">Bootstrapping an Image</a>. The detailed options for each of the header and sections are provided here.
@@ -48,7 +129,7 @@ The Docker bootstrap module will create a core operating system image based on a
48
129
Once the `Bootstrap` module has completed, the sections are identified and utilized if present. The following sections are supported in the bootstrap definition, and integrated during the bootstrap process:
49
130
50
131
51
-
####%setup
132
+
### %setup
52
133
This section blob is a Bourne shell scriptlet which will be executed on the host outside the container during bootstrap. The path to the container is accessible from within the running scriptlet environment via the variable `$SINGULARITY_ROOTFS`. For example, consider the following scriptlet:
53
134
54
135
```
@@ -65,8 +146,7 @@ As we investigate this example scriptlet, you will first see this is the outside
65
146
66
147
*note: Any uncaught command errors that occur within the scriptlet will cause the entire build process to halt!*
67
148
68
-
69
-
#### %post
149
+
### %post
70
150
Similar to the `%setup` section, this section will be executed once during bootstrapping, but this scriptlet will be run from inside the container. This is where you should put additional installation commands, downloads, and configuration into your containers. Here is an example to consider:
71
151
72
152
```
@@ -94,8 +174,26 @@ The above example runs inside the container, so in this case we will first insta
94
174
95
175
*another note: This is not a good example of a reproducible definition because it is pulling Open MPI from a moving target. A better example, would be to pull a static released version, but this serves as a good example of building a `%post` scriptlet.*
96
176
177
+
### %environment
178
+
Beginning with Singularity v2.3 you can set up your environment using the `%environment` section of the definition file. For example, if you wanted to add a directory to your search path, you could do so like this.
179
+
180
+
```
181
+
%environment
182
+
export PATH=/opt/good/stuff:$PATH
183
+
```
184
+
185
+
In older versions of Singularity you could set up your container's environment by adding text to a file called `/environment`. This method is now deprecated. If you need to add environment variables to your container during the `%post` section (perhaps because you will not know the values of some variables until some installation steps have completed). You can do so with the following syntax:
Text in the `%environment` section will be appended to a file called `/.singularity.d/env/90-environment.sh`. Text redirected to the `$SINGULARITY_ENVIRONMENT` variable will added to a file called `/.singularity.d/env/91-environment.sh`. At runtime, scripts in `/.singularity/env` are sourced in order.
193
+
194
+
This means that variables in `$SINGULARITY_ENVIRONMENT` take precedence over those added via `%environment`.
97
195
98
-
####%runscript
196
+
### %runscript
99
197
The `%runscript` is another scriptlet, but it does not get executed during bootstrapping. Instead it gets persisted within the container to a file called `/singularity` which is the execution driver when the container image is ***run*** (either via the `singularity run` command or via executing the container directly).
100
198
101
199
When the `%runscript` is executed, all options are passed along to the executing script at runtime, this means that you can (and should) manage argument processing from within your runscript. Here is an example of how to do that:
@@ -108,7 +206,7 @@ When the `%runscript` is executed, all options are passed along to the executing
108
206
109
207
In this particular runscript, the arguments are printed as a single string (`$*`) and then they are passed to `/usr/bin/python` via a quoted array (`$@`) which ensures that all of the arguments are properly parsed by the executed command. The `exec` command causes the given command to replace the current entry in the process table with the one that is to be called. This makes it so the runscript shell process ceases to exist, and the only process running inside this container is the called Python command.
110
208
111
-
####%test
209
+
### %test
112
210
You may choose to add a `%test` section to your definition file. This section will be run at the very end of the boostrapping process and will give you a chance to validate the container during the bootstrap process. If you are building on Singularity Hub, [it is a good practice](https://github.com/singularityhub/singularityhub.github.io/wiki/Generate-Images#add-tests) to have this test section so you can be sure that your container works as expected. A non-zero status code indicates that one or more of your tests did not pass. You can also execute this scriptlet through the container itself, such that you can always test the validity of the container itself as you transport it to different hosts. Extending on the above Open MPI `%post`, consider this example:
Copy file name to clipboardExpand all lines: pages/docs/user-docs/docs-environment-metadata.md
+17-7Lines changed: 17 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,16 @@
1
1
---
2
-
title: Changing Existing Containers
2
+
title: Environment and Metadata
3
3
sidebar: user_docs
4
4
permalink: docs-environment-metadata
5
5
folder: docs
6
+
toc: false
6
7
---
7
8
8
-
## Container Metadata
9
+
Singularity containers support environment variables and labels that can be added by user during the bootstrap process.
9
10
10
-
Singularity containers have two level of metadata - environment variables, and labels from the user and bootstrap process.
11
+
{% include toc.html %}
11
12
12
-
###Environment
13
+
## Environment
13
14
14
15
If you are importing a Docker container, the environment will be imported as well. If you want to define custom environment variables in your bootstrap recipe file `Singularity` you can do that like this
15
16
@@ -18,10 +19,19 @@ Bootstrap:docker
18
19
From: ubuntu:latest
19
20
20
21
%environment
21
-
VARIABLE_NAME=VARIABLE_VALUE
22
-
export VARIABLE_NAME
22
+
VARIABLE_NAME=VARIABLE_VALUE
23
+
export VARIABLE_NAME
23
24
```
24
25
26
+
If you need to add an environment variable to your container during the `%post` section, you can do so using the `$SINGULARITY_ENVIRONMENT` variable with the following syntax:
Text in the `%environment` section will be appended to the file `/.singularity.d/env/90-environment.sh` while text redirected to `$SINGULARITY_ENVIRONMENT` will end up in the file `/.singularity.d/env/91-environment.sh`. Because files in `/.singularity.d/env` are sourced in alpha-numerical order, this means that variables added using `$SINGULARITY_ENVIRONMENT` take precedence over those added via the `%environment` section.
34
+
25
35
Forget something, or need a variable defined at runtime? You can set any variable you want inside the container by prefixing it with "SINGULARITYENV_". It will be transposed automatically and the prefix will be stripped. For example, let's say we want to set the variable `HELLO` to have value `WORLD`. We can do that as follows:
0 commit comments