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/overview/start.md
+74-23Lines changed: 74 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,10 +3,11 @@ title: Quick Start
3
3
sidebar: main_sidebar
4
4
permalink: quickstart
5
5
folder: docs
6
-
toc: false
6
+
toc: true
7
7
---
8
8
9
9
## Installation Quick Start
10
+
Note that this quickstart is intended for using Singularity on your personal workstation, where you have installed Singularity and have sudo. If you only have access to Singularity on a shared cluster resource, you will be able to go through all parts of this tutorial that do not require writing to an image. First, if you are on your local machine, let's install Singularity.
10
11
11
12
```bash
12
13
git clone {{ site.repo }}.git
@@ -17,7 +18,10 @@ make
17
18
sudo make install
18
19
```
19
20
21
+
Installing Singularity as a user, or without sudo, will not produce software that works properly. If you want Singularity on your shared cluster resource, you should ask an administrator to install it for you!
22
+
20
23
## Command Quick Start
24
+
This first section of commands can be done on a shared resource, or your personal computer. You don't need sudo to create, import, or shell into containers.
Another easy way to obtain and use a container is to pull it directly. Here we can pull centos directly from Docker Hub, or pull an image from Singularity Hub.
Did you notice anything interesting about the output to the terminal? If you noticed that the above output for "pull" is similar to the output of "create" and "import" combined, you nailed it on the head! In the context of docker, running the `pull` command is an easy shortcut to create and import docker layers to an image. Whereas Docker creates and imports layers into an image on pull, when we pull (or run, or shell) an image from Singularity Hub, the entire image is downloaded. This is one of the main differences between Docker and Singularity:
Now let's go back to the `centos7.img` we created, and shell inside.
45
79
46
80
```bash
47
81
singularity shell centos7.img
@@ -61,45 +95,59 @@ Want to keep the container's environment contained, meaning no sharing of host e
61
95
singularity shell --contain centos7.img
62
96
```
63
97
64
-
### Writing in the container
65
-
By default, containers run in read only. While we discourage making tweaks on the fly to containers (you should properly define all edits to the container in a boostrap specification file, shown later) you can add `--writable` to any command to write inside the container. Let's make a directory. This command must be done with sudo.
Singularity `exec` will send a custom command for the container to run, anything that you like! Unlike docker exec, the container doesn't have to be actively running. So, to list the `/data` folder we just bound, we could do the following:
99
+
Singularity `exec` will send a custom command for the container to run, anything that you like! Unlike docker exec, the container doesn't have to be actively running. So, to list the root of the image (`/`), we could do the following:
By default, most configurations will mount `/tmp` and the home directories by default. On a research cluster, you probably want to access locations with big datasets, and then write results too. For this, you will want to bind a folder to the container. Here, we are binding my Desktop to the data folder, and listing the contents to show it worked. We use the command `-B` or `--bind` to do this.
118
+
By default, most configurations will mount `/tmp` and the home directories by default. On a research cluster, you probably want to access locations with big datasets, and then write results too. For this, you will want to bind a folder to the container. Here, we are binding my Desktop to `/opt` in the image, and listing the contents to show it worked. We use the command `-B` or `--bind` to do this.
95
119
96
120
```bash
97
-
$ singularity exec --bind /home/vanessa/Desktop:/data centos7.img ls /data
121
+
$ singularity exec --bind /home/vanessa/Desktop:/opt centos7.img ls /opt
The next set of actions, namely anything with `--writable` or bootstrap, do require you to use sudo. If you have been working on your shared resource, you will need to move to your personal laptop (and install Singularity if you haven't yet) before trying these out.
129
+
130
+
131
+
### Writing in the container
132
+
By default, containers run in read only. While we discourage making tweaks on the fly to containers (you should properly define all edits to the container in a boostrap specification file, shown later) you can add `--writable` to any command to write inside the container. Assuming we have our `centos7.img` on our local resource with sudo, let's make a directory.
We(ideally) would have done this action with bootstrap, discussed next.
150
+
103
151
### Bootstrap Recipes
104
152
For a reproducible container, the recommended practice is to build by way of a bootstrap file. This also makes it easy to add files, environment variables, and install custom software, and still start from your bootstrap of source (e.g., Docker). Here is what a basic bootstrap file looks like for Singularity 2.3:
105
153
@@ -118,7 +166,8 @@ exec echo "The runscript is the containers default runtime command!"
118
166
119
167
120
168
%environment
121
-
VARIABLE MEATBALLVALUE
169
+
VARIABLE=MEATBALLVALUE
170
+
export VARIABLE
122
171
123
172
%labels
124
173
AUTHOR vsochat@stanford.edu
@@ -130,10 +179,12 @@ mkdir /data
130
179
echo"The post section is where you can install, and configure your container."
131
180
```
132
181
133
-
The above bootstrap definition can then be run with singularity. Assuming that the definition was saved as `ubuntu.def` and an image file `ubuntu.img` exists, the following will build the container.
182
+
The above bootstrap definition can then be run with singularity. Assuming that the definition was saved as `Singularity` and an image file `ubuntu.img` exists, the following will build the container.
134
183
135
184
```bash
136
-
singularity bootstrap ubuntu.img ubuntu.def
185
+
sudo singularity bootstrap ubuntu.img Singularity
137
186
```
138
187
188
+
How might you go through this entire process without having singularity installed locally, or without leaving your cluster? You can build images using <a href="https://github.com/singularityhub/singularityhub.github.io/wiki" target="_blank">singularity hub.</a>
0 commit comments