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: _posts/releases/2017-10-02-release-2.4.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Building an image is now more intuitive with the introduction of our `build` com
17
17
sudo singularity build container.simg Singularity
18
18
```
19
19
20
-
If you are tired of needing to estimate your image size, that issue goes away with build. The default format for a Singularity image base is now a smaller, compressed file format called **SquashFS**. This format is also a much better fit for reproducible containers, as it is immutable. For more details, see our [build](/docs-build) documentation.
20
+
If you are tired of needing to estimate your image size, that issue goes away with build. The default format for a Singularity image base is now a smaller, compressed file format called **SquashFS**. This format is also a much better fit for reproducible containers, as it is immutable. For more details, see our [build](/docs-build-container) documentation.
21
21
22
22
**Build Bases**
23
23
We originally supported just using an existing distribution package or docker as a base for building images. With 2.4, we have extended that set to include another Singularity image (`localimage`), a Singularity Hub or Registry image (`shub`) or the host operating system (`self`).
Copy file name to clipboardExpand all lines: pages/docs/user-docs/action-bootstrap.md
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,9 @@ folder: docs
6
6
toc: false
7
7
---
8
8
9
-
>>Note: The bootstrap command is deprecated for Singularity Version 2.4. You should use <ahref="/build"target="_blank">build</a> instead.
9
+
> Note: The bootstrap command is deprecated for Singularity Version 2.4. You should use [build](/build-a-container) instead.
10
10
11
-
Bootstrapping was the original way (for Singularity versions prior to 2.4) to install an operating system and then configure it appropriately for a specified need. Bootstrap is very similar to build, except that it by default uses an <ahref="https://en.wikipedia.org/wiki/Ext3"target="_blank">ext3</a> filesystem and allows for writability. The images unfortunately are not immutable in this way, and can degrade over time. As of 2.4, bootstrap is still supported for Singularity, however we encourage you to use <ahref="/build"target="_blank">build</a> instead.
12
-
13
-
{% include toc.html %}
11
+
Bootstrapping was the original way (for Singularity versions prior to 2.4) to install an operating system and then configure it appropriately for a specified need. Bootstrap is very similar to build, except that it by default uses an <ahref="https://en.wikipedia.org/wiki/Ext3"target="_blank">ext3</a> filesystem and allows for writability. The images unfortunately are not immutable in this way, and can degrade over time. As of 2.4, bootstrap is still supported for Singularity, however we encourage you to use [build](/build-a-container) instead.
`build`is the "Swiss army knife" of container creation. You can use it to download and assemble existing containers from external resources like [Singularity Hub](https://singularity-hub.org/) and [Docker Hub](https://hub.docker.com/). You can use it to convert containers between the various formats supported by Singularity. And you can use it in conjunction with a [Singularity recipe](/docs-recipes) file to create a container from scratch and customized it to fit your needs.
9
+
Use `build` to download and assemble existing containers, convert containers from one format to another, or build a container from a [Singularity recipe](/docs-recipes).
10
10
11
11
{% include toc.html %}
12
12
13
13
## Overview
14
-
The `build` command accepts a target as input and produces a container as output.
14
+
The `build` command accepts a target as input and produces a container as output. The target can be a Singularity Hub or Docker Hub URI, a path to an existing container, or a path to a Singularity Recipe file. The output container can be in squashfs, ext3, or directory format.
15
15
16
-
The target defines the method that `build`uses to create the container. It can be one of the following:
16
+
For a complete list of `build`options type `singularity help build`. For more info on building containers see [Build a Container](docs-build-container).
17
17
18
-
- URI beginning with **shub://** to build from Singularity Hub
19
-
- URI beginning with **docker://** to build from Docker Hub
20
-
- path to a **existing container** on your local machine
21
-
- path to a **directory** to build from a sandbox
22
-
- path to an **archive** in .tar or compressed .tar.gz format
23
-
- path to a **[Singularity recipe file](docs-recipes)**
24
-
25
-
In addition `build` can produce containers in three different formats. Formats types can be specified by passing the following options to build.
26
-
27
-
- compressed read-only **squashfs** file system suitable for production (default)
28
-
- writable **ext3** file system suitable for interactive development (`--writable` option)
29
-
- writable **(ch)root directory** called a sandbox for interactive development (`--sandbox` option)
30
-
31
-
Because `build` can accept an existing container as a target and create a container in any of these three formats you can convert existing containers from one format to another.
32
-
33
-
The following diagram illustrates the targets that can be supplied to `build` as inputs and the containers `build` can produce as outputs. Green arrows represent operations that can be carried out without root privileges (though the container may not perform properly when run as root). Red arrows represent operations that must be carried out with root privileges.
The first argument (`lolcow.simg`) specifies a path and name for your container. The second argument (`shub://GodloveD/lolcow`) gives the Singularity Hub URI from which to download.
49
-
50
-
But default the container will be converted to a compressed, read-only squashfs file. If you want your container in a different format use the `--writable` or `--sandbox` options.
51
-
52
-
## Downloading a existing container from Docker Hub
53
-
You can use `build` to download layers from Docker Hub and assemble them into Singularity containers.
The same information applies to containers built from Docker Hub and containers built from Singularity Hub.
60
-
61
-
## Creating `--writable` images and `--sandbox` directories
62
-
63
-
### `--writable`
64
-
If you wanted to create a writable ext3 image similar to those used by Singularity version < 2.4, you could do so with the `--writable` option. You must create writable containers as root.
65
-
66
-
Extending the Singularity Hub example from above:
26
+
### Create `--writable` images and `--sandbox` directories
The resulting container is writable, but is still mounted as read-only when executed with commands such as `run`, `exec`, and `shell`. To mount the container as read-write when using these commands add the `--writable` option to them as well.
74
-
75
-
To ensure that you have the proper permissions to write to the container as you like, it is also a good idea to make changes as root. For example:
76
-
77
-
```
78
-
$ sudo singularity shell --writable lolcow.img
79
-
```
80
-
81
-
### `--sandbox`
82
-
If you wanted to create a container within a writable directory (called a _sandbox_) you could do so with the `--sandbox` option. It's possible to create a sandbox without root privileges, but to ensure proper file permissions it is recommended to do so as root.
The resulting directory operates just like a container in an image file. You are permitted to make changes and write files within the directory, but those changes will not persist when you are finished using the container. To make your changes persistent, use the `--writable` flag when you invoke your container.
89
-
90
-
Once again, it's a good idea to do this as root to ensure you have permission to access the files and directories that you want to change.
91
-
92
-
```
93
-
$ sudo singularity shell --writable lolcow/
94
-
```
95
-
96
-
## Converting containers from one format to another
97
-
If you already have a container saved locally, you can use it as a target to build a new container. This allows you convert containers from one format to another. For example if you had a squashfs container called `production.simg` and wanted to convert it to a writeable ext3 container called `development.img` you could:
98
-
33
+
### Convert containers from one format to another
34
+
You can convert the three supported container formats using any combination.
If you omit any options you can also convert your sandbox back to a read-only compressed squashfs image suitable for use in a production environment:
110
-
111
-
```
112
38
$ singularity build production2 development/
113
39
```
114
-
You can convert the three supported container formats using any combination.
115
-
116
-
Use care when converting writable ext3 images or sandbox directories to the default squashfs file format. If changes were made to the writable container before conversion, there is no record of those changes in the Singularity recipe file rendering your container non-reproducible. It is a best practice to build your immutable production containers directly from a Singularity recipe file instead.
117
-
118
-
## Building containers from Singularity recipe files
119
-
Of course, Singularity recipe files can be used as the target when building a container. For detailed information on writing Singularity recipe files, please see [the Container Recipes docs](docs-recipes).
120
-
121
-
Let's say you already have the following container recipe file called `Singularity`, and you want to use it to build a container.
122
-
123
-
```
124
-
BootStrap: docker
125
-
From: ubuntu:16.04
126
-
127
-
%post
128
-
apt-get -y update
129
-
apt-get -y install fortune cowsay lolcat
130
40
131
-
%environment
132
-
export LC_ALL=C
133
-
export PATH=/usr/games:$PATH
134
-
135
-
%runscript
136
-
fortune | cowsay | lolcat
137
-
```
138
-
139
-
You can do so with the following command.
41
+
### Build a container from a Singularity recipe
42
+
Given a Singularity Recipe called `Singularity`:
140
43
141
44
```
142
45
$ sudo singularity build lolcow.simg Singularity
143
46
```
144
47
145
-
The command requires `sudo` just as installing software on your local machine requires root privileges.
146
-
147
-
### `--force`
148
-
You can build into the same container multiple times (though the results may be unpredictable and it is generally better to delete your container and start from scratch).
149
-
150
-
By default if you build into an existing container, the `build` command will skip the steps involved in adding a new base. You can override this default with the `--force` option requiring that a new base OS is bootstrapped into the existing container. This behavior does not delete the existing OS, it just adds the new OS on top of the existing one.
151
-
152
-
Use care with this option: you may get results that you did not expect.
153
-
154
-
### `--section`
155
-
If you only want to build a single section of your Singularity recipe file use the `--section` option. For instance, if you have edited the `%environment` section of a long Singularity recipe and don't want to completely re-build the container, you could re-build only the `%environment` section like so:
Under normal build conditions, the Singularity recipe file is saved into a container's meta-data so that there is a record showing how the container was built. Using the `--section` option may render this meta-data useless, so use care if you value reproducibility.
162
-
163
-
### `--notest`
164
-
If you don't want to run the `%test` section during the container build, you can skip it with the `--notest` option. For instance, maybe you are building a container intended to run in a production environment with GPUs. But perhaps your local build resource does not have GPUs. You want to include a `%test` section that runs a short validation but you don't want your build to exit with an error because it cannot find a GPU on your system.
Checks are a new feature (in 2.4) that offer an easy way for an admin to define a security (or any other kind of check) to be run on demand for a Singularity image. They are defined (and run) via different tags.
When you add the `--checks` option along with applicable tags to the `build` command Singularity will run the desired checks on your container at build time. See `singularity check --help` for available tags.
183
-
184
-
185
-
## More Build topics
186
-
- If you want to **customize the cache location** (where Docker layers are downloaded on your system), specify Docker credentials, or any custom tweaks to your build environment, see <ahref="/build-environment">build environment</a>.
187
-
- If you want to make internally **modular containers**, check out <ahref="http://containers-ftw.org/apps/examples/tutorials/getting-started"target="_blank">this post</a>.
188
-
- If you want to **build your containers** on Singularity Hub, (because you don't have root access on a Linux machine or want to host your container on the cloud) check out [this guide](https://github.com/singularityhub/singularityhub.github.io/wiki).
189
-
190
48
<script>
191
49
// Without this, pagination links to exec under repeated build section
Copy file name to clipboardExpand all lines: pages/docs/user-docs/action-run.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,7 +59,7 @@ When you first create a container, the runscript is defined using the following
59
59
4. If the user has not defined a runscript and the Docker container doesn't have an `ENTRYPOINT`, we look for `CMD`, even if the user hasn't asked for it.
60
60
5. If the user has not deifned a runscript, and there is no `ENTRYPOINT` or `CMD` (or we aren't importing Docker at all) then we default to `/bin/bash`
61
61
62
-
Here is how you would define the runscript section when you [build](/docs-build) an image:
62
+
Here is how you would define the runscript section when you [build](/docs-build-container) an image:
0 commit comments