Skip to content

Commit bc235b2

Browse files
authored
Merge pull request #103 from vsoch/docs/2.4
undoing my mistakes
2 parents 63e16eb + 345976f commit bc235b2

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

pages/docs/user-docs/docs-bootstrap-image.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ You can add environment variables to be sourced when the container is used in th
152152
export VADER LUKE SOLO
153153
```
154154

155+
You can also add environment variables to your container in the `%post` section (see below) using the following syntax:
156+
157+
```
158+
%post
159+
echo 'export JAWA_SEZ=wutini' >>$SINGULARITY_ENVIRONMENT
160+
```
161+
162+
Variables added to your container using the `$SINGULARITY_ENVIRONMENT` syntax take precedence over those added in the `%environment` section.
163+
155164
See <a href="/docs-environment-metadata">Environment and Metadata</a> for more information about the `%labels` and `%environment` sections.
156165

157166

pages/docs/user-docs/docs-bootstrap.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ Beginning with Singularity v2.3 you can set up your environment using the `%envi
101101
export PATH=/opt/good/stuff:$PATH
102102
```
103103

104+
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:
105+
106+
```
107+
%post
108+
echo 'export PATH=/opt/good/stuff:$PATH' >>$SINGULARITY_ENVIRONMENT
109+
```
110+
111+
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.
112+
113+
This means that variables in `$SINGULARITY_ENVIRONMENT` take precedence over those added via `%environment
114+
104115
### %runscript
105116
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).
106117

pages/docs/user-docs/docs-environment-metadata.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ From: ubuntu:latest
2323
export VARIABLE_NAME
2424
```
2525

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:
27+
28+
```
29+
%post
30+
echo 'export VARIABLE_NAME=VARIABLE_VALUE' >>$SINGULARITY_ENVIRONMENT
31+
```
32+
33+
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+
2635
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:
2736

2837
```bash
@@ -78,7 +87,7 @@ singularity inspect dino.img
7887
}
7988
```
8089

81-
You will notice that the one label doesn't belong to the label schema, `MAINTAINER`. This was a user provided label during bootstrap. For versions earlier than 2.4, containers did not use the label schema:
90+
You will notice that the one label doesn't belong to the label schema, `MAINTAINER`. This was a user provided label during bootstrap. Finally, for Singularity greater than version 2.4, the image build size is added as a label, `org.label-schema.build-size`, and the label schema is used, period. For versions earlier than 2.4, containers did not use the label schema, and looked like this:
8291

8392

8493
```bash

0 commit comments

Comments
 (0)