Skip to content

Commit 63e16eb

Browse files
authored
Sanity check for merging updated master into docs/2.4 (#102)
* adding troubleshooting for debian issue apptainer/singularity#845 * adding note about security implications * Typo: dummpy.img -> dummy.img (#94) Not sure if this was a typo or a snarky insider joke by a Perl/Ruby programmer.... * Typo: One -> On & wordsmithing (#95) * Type: One -> On * Wordsmithing * Fix inaccurate docker command description (#96) There is no `docker -ps` command. The docker `ps` subcommand lists containers. The docker `history` subcommand will list the layers, like so: ``` hartzelg@blah:~$ docker history hartzelg/cime IMAGE CREATED CREATED BY SIZE COMMENT 7185c64fa2a5 5 months ago /bin/sh -c #(nop) VOLUME [/cime_config.yaml] 0 B fd53e85b356b 5 months ago /bin/sh -c #(nop) VOLUME [/var/jenkins_home] 0 B b50f22ae6ec1 5 months ago /bin/sh -c #(nop) COPY file:fb917d778dfa959bb 10.11 kB [...] ``` * Typo: maybe -> may be (#97) * Oops: "pids" -> "numeric userid" (#98) "pids" is process ids, I think? What you mean is the users numeric id, e.g. on machine A `hartzell` is `3245` so files are owned by `3245`. But, when I get to machine B where `hartzell` is `22453`, those same files appear to be someone else. Right? * nothing to see here... * fixing environment variable example * Fix typo (#99) * $SINGULARITY_ENVIRONMENT, --nv, and random cleanup * removed Usage sections from commands * removed $SINGULARITY_ENVIRONMENT jazz from current docs * reverted docs-usage to old version * cleaning up the merge a bit more * finalizing and approving PR to close #100!
1 parent 94b7ffd commit 63e16eb

17 files changed

+163
-213
lines changed

_posts/recipes/2017-05-09-hostlibs-gpus-and-mpi.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ category: recipes
44
permalink: tutorial-gpu-drivers-open-mpi-mtls
55
---
66

7+
**Note: _Much of the GPU portion of this tutorial is deprecated by the `--nv`
8+
option that automatically binds host system driver libraries into your
9+
container at runtime. See the [`exec`](/docs-exec#a-gpu-example) command for
10+
an example_**
11+
712
Singularity does a fantastic job of isolating you from the host so you don't
813
have to muck about with `LD_LIBRARY_PATH`, you just get exactly the library
914
versions you want. However, in some situations you need to use library

pages/docs/contributing/contributing-docs.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ title: Contributing to Documentation
33
sidebar: main_sidebar
44
permalink: contributing-docs
55
folder: releases
6+
toc: false
67
---
78

89
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!
910

1011
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.
1112

13+
{% include toc.html %}
1214

1315
## Setting Up Your Development Environment
1416

@@ -113,8 +115,16 @@ asciinema rec -w 1 demo-asciicast.js
113115
# To play
114116
asciinema play demo-asciicast.js
115117
```
118+
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. To get the size of your current terminal (in lines and columns) you can use `tput`:
116120

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+
```
122+
echo -e "lines\ncols"|tput -S
123+
34
124+
80
125+
```
126+
127+
Once you've generated an asciicast, you should drop the file (e.g., `demo-asciicast.js`) into the `assets/asciicast` folder. Since we will have many asciicasts here, please name it meaningfully. Then include the following in the page or post:
118128

119129
```bash
120130
{{ "{% include asciicast.html source='demo-asciicast.js' title='How to make demos' author='[email protected]'" }}%}

pages/docs/overview/faq.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ See the Singularity on HPC page for more details.
213213

214214
### Does Singularity support containers that require GPUs?
215215

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`](/docs-exec#a-gpu-example) command for
219+
an example.
217220

218221
## Container portability
219222

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ title: Getting Started with Bootstrap
33
sidebar: user_docs
44
permalink: bootstrap-image
55
folder: docs
6+
toc: false
67
---
78

8-
## Bootstrapping a Container
99
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.
1010

1111
{% include toc.html %}
@@ -142,7 +142,17 @@ Version 2.0
142142
```
143143

144144
#### %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 <a href="/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+
VADER=badguy
150+
LUKE=goodguy
151+
SOLO=someguy
152+
export VADER LUKE SOLO
153+
```
154+
155+
See <a href="/docs-environment-metadata">Environment and Metadata</a> for more information about the `%labels` and `%environment` sections.
146156

147157

148158
#### %post

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ toc: false
66
folder: docs
77
---
88

9-
{% include toc.html %}
10-
119
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 <a href="/bootstrap-image">Bootstrapping an Image</a>. The detailed options for each of the header and sections are provided here.
1210

11+
{% include toc.html %}
12+
1313
## The header fields:
1414

1515
### Bootstrap:
@@ -48,7 +48,7 @@ The Docker bootstrap module will create a core operating system image based on a
4848
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:
4949

5050

51-
#### %setup
51+
### %setup
5252
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:
5353

5454
```
@@ -65,8 +65,7 @@ As we investigate this example scriptlet, you will first see this is the outside
6565

6666
*note: Any uncaught command errors that occur within the scriptlet will cause the entire build process to halt!*
6767

68-
69-
#### %post
68+
### %post
7069
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:
7170

7271
```
@@ -94,8 +93,15 @@ The above example runs inside the container, so in this case we will first insta
9493

9594
*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.*
9695

96+
### %environment
97+
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.
98+
99+
```
100+
%environment
101+
export PATH=/opt/good/stuff:$PATH
102+
```
97103

98-
#### %runscript
104+
### %runscript
99105
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).
100106

101107
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 +114,7 @@ When the `%runscript` is executed, all options are passed along to the executing
108114

109115
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.
110116

111-
#### %test
117+
### %test
112118
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:
113119

114120
```

pages/docs/user-docs/docs-changing-containers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ folder: docs
77

88

99
# Making Changes to an Existing Container
10-
It is possible that you may need to make changes to a container after it has been bootstrapped. For that, let's repeat the Singularity mantra "*A user inside a Singularity container is the same user as outside the container*". If you want to make changes to your container, you must mount the container as `--writable` so you can change the contents. Note that standard Linux ownership and permission rules pertain to files within the container, so the `--writable` option does not guarantee you can do things like install new software. This might be a bit confusing if you copy a container from one computer to another. If your pids are different on the two computers you will lose the ability to edit files you previous had write access to. In these instances, it might be best to modify your container as root and so you would first need to become root outside of the container. Let's examine the following example:
10+
It is possible that you may need to make changes to a container after it has been bootstrapped. For that, let's repeat the Singularity mantra "*A user inside a Singularity container is the same user as outside the container*". If you want to make changes to your container, you must mount the container as `--writable` so you can change the contents. Note that standard Linux ownership and permission rules pertain to files within the container, so the `--writable` option does not guarantee you can do things like install new software. This might be a bit confusing if you copy a container from one computer to another. If your numeric userid are different on the two computers you will lose the ability to edit files you previous had write access to. In these instances, it might be best to modify your container as root and so you would first need to become root outside of the container. Let's examine the following example:
1111

1212
## Installing Additional Software
1313
We strongly recommend that you add additional software installation to your bootstrap, and re-create the image. However if you must, you can use `shell` and `exec` with `--writable` to issue additional commands.

pages/docs/user-docs/docs-create-an-image.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ folder: docs
77

88
A Singularity image, which can be referred to as a "container," is a single file that contains a virtual file system. After creating an image you can install an operating system, applications, and save meta-data with it.
99

10-
Whereas Docker assembles images from layers that are stored on your computer (viewed with the docker -ps command), a Singularity image is just one file that can sit on your Desktop, in a folder on your cluster, or anywhere.
10+
Whereas Docker assembles images from layers that are stored on your computer (viewed with the `docker history` command), a Singularity image is just one file that can sit on your Desktop, in a folder on your cluster, or anywhere.
1111

1212
Having Singularity containers housed within a single image file greatly simplifies management tasks such as sharing, copying, and branching your containers. It also means that standard Linux file system concepts like permissions, ownership, and ACLs apply to the container (e.g. I can give read only access to a colleague, or block access completely with a simple chmod command).
1313

pages/docs/user-docs/docs-docker.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ From: tensorflow/tensorflow:latest
125125
relative_path.py /tmp/analysis2.py
126126

127127
%environment
128-
129-
TOPSECRET pancakes
130-
HELLO WORLD
128+
TOPSECRET=pancakes
129+
HELLO=WORLD
130+
export HELLO TOPSECRET
131131

132132
%labels
133133

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
2-
title: Changing Existing Containers
2+
title: Environment and Metadata
33
sidebar: user_docs
44
permalink: docs-environment-metadata
55
folder: docs
6+
toc: false
67
---
78

8-
## Container Metadata
9+
Singularity containers support environment variables and labels that can be added by user during the bootstrap process.
910

10-
Singularity containers have two level of metadata - environment variables, and labels from the user and bootstrap process.
11+
{% include toc.html %}
1112

12-
13-
### Environment
13+
## Environment
1414

1515
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
1616

@@ -19,7 +19,8 @@ Bootstrap:docker
1919
From: ubuntu:latest
2020

2121
%environment
22-
VARIABLE_NAME=VARIABLE_VALUE
22+
VARIABLE_NAME=VARIABLE_VALUE
23+
export VARIABLE_NAME
2324
```
2425

2526
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:
@@ -58,7 +59,7 @@ singularity exec centos7.img cat /.singularity.d/env/10-docker.sh
5859
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
5960
```
6061

61-
### Labels
62+
## Labels
6263
Your container stores metadata about it's build, along with Docker labels, and your custom labels that you define in a bootstrap `%labels` section. For containers that are generated with Singularity version 2.4 and later, labels are represented using the <a href="http://label-schema.org/rc1/">rc1 Label Schema</a>. For example:
6364

6465
```

0 commit comments

Comments
 (0)