Skip to content

Commit 6e8a2a2

Browse files
authored
Merge pull request #121 from GodloveD/DCG-edits2
DCG edits
2 parents 4518b46 + 67bc7ca commit 6e8a2a2

11 files changed

Lines changed: 309 additions & 409 deletions

File tree

_data/sidebars/user_docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ entries:
2323
url: /quickstart
2424
output: web, pdf
2525

26-
- title: Build an Image
26+
- title: Build a Container
2727
url: /docs-build
2828
output: web, pdf
2929

assets/img/diagram/build_input_output.svg

Lines changed: 4 additions & 0 deletions
Loading

pages/docs/user-docs/action-build.md

Lines changed: 106 additions & 220 deletions
Large diffs are not rendered by default.

pages/docs/user-docs/action-mount.md

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

9-
{% include toc.html %}
9+
Singularity allows you to map directories on your host system to directories within your container using bind mounts. This allows you to read and write data on the host system with ease.
1010

11-
## Bind Paths
12-
Singularity 'swaps' out the currently running root operating system on the host for what is inside the container, and in doing so none of the host file systems are accessible anymore. As a workaround for this, Singularity will *bind* those paths back in via two primary methods: system defined bind points and conditional user defined bind points.
11+
{% include toc.html %}
1312

14-
{% include asciicast.html source='docs-create-rootmount.js' uid='how-to-mount-and-copy' title='How to mount an image and copy files to it' author='davidgodlove@gmail.com'%}
13+
## Overview
14+
When Singularity 'swaps' the host operating system for the one inside your container, the host file systems becomes inaccessible. But you may want to read and write files on the host system from within the container. To enable this functionality Singularity will *bind* directories back in via two primary methods: system defined bind points and conditional user defined bind points.
1515

16-
To *mount* a bind path inside the container, a ***bind point*** must be defined within the container. The bind point is a target location entity to which the actual directory or file can be bound to. This means that if you want to bind to a point within the container such as `/global`, that directory must already exist within the container.
16+
To *mount* a bind path inside the container, a **bind point** must be defined within the container. The bind point is a directory within the container that Singularity can use to bind a directory on the host system. This means that if you want to bind to a point within the container such as `/global`, that directory must already exist within the container.
1717

18-
It is however possible that the system administrator has enabled a Singularity feature called *overlay* in the `/etc/singularity/singularity.conf` file. This will cause the bind points to be created on an as needed basis in an overlay file system so that the underlying container is not modified. But because the *overlay* feature is not always used, it maybe necessary for container standards to exist to ensure portability from host to host.
18+
It is however possible that the system administrator has enabled a Singularity feature called *overlay* in the `/etc/singularity/singularity.conf` file. This will cause the bind points to be created on an as needed basis so that the underlying container is not modified. But because the *overlay* feature is not always used or unavailable in some kernels, it maybe necessary for container standards to exist to ensure portability from host to host.
1919

20-
If a bind path is requested, and the bind point does not exist within the container, a warning message will be displayed, and Singularity will continue trying to mount file system. For example:
20+
If a bind path is requested, and the bind point does not exist within the container, a warning message will be displayed, and Singularity will continue trying to start the container. For example:
2121

2222
```bash
23-
$ singularity shell /tmp/Centos7-ompi.img
23+
$ singularity shell --bind /global /tmp/Centos7-ompi.img
2424
WARNING: Non existant bind point (directory) in container: '/global'
2525
Singularity: Invoking an interactive shell within container...
2626

@@ -30,17 +30,17 @@ Singularity.Centos7-ompi.img>
3030
Even though `/global` did not exist inside the container, the shell command printed a warning but continued on. If we enable `enable overlay = yes` in the `/etc/singularity/singularity.conf` you will find that we no longer get the error and `/global` is created and accessible as expected:
3131

3232
```bash
33-
$ singularity shell /tmp/Centos7-ompi.img
33+
$ singularity shell --bind /global /tmp/Centos7-ompi.img
3434
Singularity: Invoking an interactive shell within container...
3535

3636
Singularity.Centos7-ompi.img>
3737
```
3838

39-
#### System defined bind points
39+
### System defined bind points
4040
The system administrator has the ability to define what bind points will be included automatically inside each container. The bind paths are locations on the host's root file system which should also be visible within the container. Some of the bind paths are automatically derived (e.g. a user's home directory) and some are statically defined (e.g. `bind path = ` in `/etc/singularity/singularity.conf`).
4141

4242

43-
#### User defined bind points
43+
### User defined bind points
4444
If the system administrator has enabled user control of binds (via `user bind control = yes` in `/etc/singularity/singularity.conf`), you will be able to request your own bind points within your container.
4545

4646
Further, if the administrator has enabled the use of file system overlay (via `enable overlay = yes` in `/etc/singularity/singularity.conf`), you can bind host system directories to directories that do not exist within the container. Singularity will dynamically create the necessary bind points in your container on demand. This feature may not be supported on older host systems.

pages/docs/user-docs/docs-checks.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ folder: docs
66
toc: false
77
---
88

9-
New to Singularity 2.4 is the ability to, on demand, run container "checks," which can be anything from a filter for sensitive information, to an analysis of content on the filesystem. Checks are installed with Singularity and [managed by the administration](/docs-admin-checks), however as a user they are accessible to you for use during bootstrap or on demand:
9+
New to Singularity 2.4 is the ability to run container "checks" on demand. Checks can be anything from a filter for sensitive information, to an analysis installed binaries. A few defualt checks are installed with Singularity and others can be [added by the administrater](/docs-admin-checks). Users can perform checks at build time or on demand:
1010

11+
{% include toc.html %}
12+
13+
Perform all default checks, these are the same
1114
```
12-
# Perform all default checks, these are the same
1315
$ singularity check ubuntu.img
1416
$ singularity check --tag default ubuntu.img
17+
```
1518

16-
# Perform checks with tag "clean"
19+
Perform checks with tag "clean"
20+
```
1721
$ singularity check --tag clean ubuntu.img
1822
```
1923

@@ -29,7 +33,7 @@ USAGE
2933
3034
EXAMPLE
3135
32-
singularity check --tag docker ubuntu.img
36+
$ singularity check --tag docker ubuntu.img
3337
```
3438

3539
If you want to run checks associated with a different security level, you can specify with `--low`, `--med`, or `-high`:

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

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,40 @@ folder: docs
66
toc: false
77
---
88

9-
Singularity containers support environment variables and labels that can be added by user during the bootstrap process.
9+
Singularity containers support environment variables and labels that you can add to your container during the build process.
1010

1111
{% include toc.html %}
1212

1313
## Environment
1414

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+
If you build a container from Singularity Hub or Docker Hub, the environment will be included with the container at build time. You can also define custom environment variables in your Recipe file like so:
1616

17-
```bash
18-
Bootstrap:docker
19-
From: ubuntu:latest
17+
```
18+
Bootstrap: shub
19+
From: vsoch/hello-world
2020
2121
%environment
2222
VARIABLE_NAME=VARIABLE_VALUE
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:
26+
You may need to add environment variables to your container during the `%post` section. For instance, maybe you will not know the appropriate value of a variable until you have installed some software.
27+
28+
To add variables to the environment during `%post` you can use the `$SINGULARITY_ENVIRONMENT` variable with the following syntax:
2729

2830
```
2931
%post
3032
echo 'export VARIABLE_NAME=VARIABLE_VALUE' >>$SINGULARITY_ENVIRONMENT
3133
```
3234

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.
35+
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`.
36+
37+
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.
3438

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:
39+
Need to define a variable at runtime? You can set variables inside the container by prefixing them with "SINGULARITYENV_". They 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:
3640

37-
```bash
38-
$ SINGULARITYENV_HELLO=WORLD singularity exec -e centos7.img env
41+
```
42+
$ SINGULARITYENV_HELLO=WORLD singularity exec --cleanenv centos7.img env
3943
HELLO=WORLD
4044
LD_LIBRARY_PATH=:/usr/local/lib:/usr/local/lib64
4145
SINGULARITY_NAME=test.img
@@ -47,32 +51,13 @@ SINGULARITY_INIT=1
4751
SINGULARITY_CONTAINER=test.img
4852
```
4953

50-
Notice the `-e`? That is the argument (or `--cleanenv`) that specifies that we want to remove the host environment from the container. If we remove the `-e`, we will still pass forward `HELLO=WORLD`, and the list shown above, but we will also pass forward all the other environment variables from the host. Here is a command to directly echo the variable we define:
51-
52-
```bash
53-
$echo 'echo $HELLO' | SINGULARITYENV_HELLO=WORLD singularity exec centos7.img /bin/sh
54-
WORLD
55-
```
56-
57-
If you want to look at the environment inside a container, you can look inside the metadata env folder as follows:
58-
59-
```bash
60-
singularity exec centos7.img ls /.singularity.d/env
61-
01-base.sh 10-docker.sh 99-environment.sh
62-
```
63-
64-
The variables in `01-base.sh` are a set of defaults set upon container creation, and the `10-docker.sh` come from a Docker import.
65-
66-
```bash
67-
singularity exec centos7.img cat /.singularity.d/env/10-docker.sh
68-
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
69-
```
54+
Notice the `--cleanenv` in the example above? That argument specifies that we want to remove the host environment from the container. If we remove the `--cleanenv`, we will still pass forward `HELLO=WORLD`, and the list shown above, but we will also pass forward all the other environment variables from the host.
7055

7156
## Labels
72-
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:
57+
Your container stores metadata about it's build, along with Docker labels, and custom labels that you define during build in a `%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:
7358

7459
```
75-
singularity inspect dino.img
60+
$ singularity inspect dino.img
7661
{
7762
"org.label-schema.usage.singularity.deffile.bootstrap": "docker",
7863
"MAINTAINER": "Vanessasaurus",
@@ -87,10 +72,9 @@ singularity inspect dino.img
8772
}
8873
```
8974

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:
91-
75+
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 versions >= 2.4, the image build size is added as a label, `org.label-schema.build-size`, and the label schema is used througout. For versions earlier than 2.4, containers did not use the label schema, and looked like this:
9276

93-
```bash
77+
```
9478
singularity exec centos7.img cat /.singularity.d/labels.json
9579
{ "name":
9680
"CentOS Base Image",
@@ -102,13 +86,46 @@ singularity exec centos7.img cat /.singularity.d/labels.json
10286

10387
You can add custom labels to your container in a bootstrap file:
10488

105-
```bash
89+
```
10690
Bootstrap: docker
10791
From: ubuntu: latest
10892
10993
%labels
11094
11195
AUTHOR Vanessasaur
11296
```
97+
The `inspect` command is useful for viewing labels and other container meta-data.
98+
99+
## Container Metadata
100+
101+
Inside of the container, metadata is stored in the `/.singularity.d` directory. You probably shouldn't edit any of these files directly but it may be helpful to know where they are and what they do:
102+
103+
```
104+
/.singularity.d/
105+
├── actions
106+
│ ├── exec
107+
│ ├── run
108+
│ ├── shell
109+
│ ├── start
110+
│ └── test
111+
├── env
112+
│ ├── 01-base.sh
113+
│ ├── 90-environment.sh
114+
│ ├── 95-apps.sh
115+
│ └── 99-base.sh
116+
├── labels.json
117+
├── libs
118+
├── runscript
119+
├── Singularity
120+
└── startscript
121+
```
122+
123+
- **actions**: This directory contains helper scripts to allow the container to carry out the action commands.
124+
- **env**: All *.sh files in this directory are sourced in alpha-numeric order when the container is initiated. For legacy purposes there is a symbolic link called `/environment` that points to `/.singularity.d/env/90-environment.sh`.
125+
- **labels.json**: The json file that stores a containers labels described above.
126+
- **libs**: At runtime the user may request some host-system libraries to be mapped into the container (with the `--nv` option for example). If so, this is their destination.
127+
- **runscript**: The commands in this file will be executed when the container is invoked with the `run` command or called as an executable. For legacy purposes there is a symbolic link called `/singularity` that points to this file
128+
- **Singularity**: This is the Recipe file that was used to generate the container. If more than 1 Recipe file was used to generate the conainer additional Singularity files will appear in numeric order in a sub-directory called `bootstrap_history`
129+
- **startscript**: The commands in this file will be executed when the container is invoked with the `instance.start` command.
113130

114131
{% include links.html %}

0 commit comments

Comments
 (0)