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
# The Runscript: Making containerized apps behave more like normal apps
1
+
# The Runscript: Making containerized apps behave like normal apps
2
2
3
-
We are now going to consider an extended example describing a containerized application that takes a file as input, analyzes the data in the file, and produces another file as output.
4
-
This is obviously a very common situation.
3
+
Consider an application that takes one file as input, analyzes the data in the file, and produces another file as output. This is obviously a very common situation.
5
4
6
-
Let's imagine that we want to use the cowsay program in our `lolcow.simg` to "analyze data". We should give our container an input file, it should reformat it (in the form of a cow speaking), and it should dump the output into another file.
5
+
Let's imagine that we want to use the cowsay program in our `lolcow.sif` to "analyze data". We should give our container an input file, it should reformat the text (in the form of a cow speaking), and it should dump the output into another file.
7
6
8
7
Here's an example. First I'll make some "data"
9
8
10
9
```
11
-
$ echo "The grass is always greener over the septic tank" > input
10
+
$ echo "The grass is always greener over the septic tank" > /data/input
The "analyzed data" is saved in a file called `output`.
19
+
The "analyzed data" is saved in a file called `/data/output`.
21
20
22
21
```
23
-
$ cat output
22
+
$ cat /data/output
24
23
______________________________________
25
24
/ The grass is always greener over the \
26
25
\ septic tank /
@@ -41,77 +40,55 @@ $ ./lolcow.simg
41
40
This is what happens when you run the container...
42
41
```
43
42
44
-
Let's rewrite this runscript in the definition file and rebuild our container
45
-
so that it does something more useful.
43
+
Let's rewrite this runscript in the definition file and rebuild our container so that it does something more useful. And while we're at it, we'll change the bootstrap method to `library`
Note the `--force` option which ensures our previous container is completely overwritten.
104
71
105
-
After rebuilding our container, we can call the lolcow.simg as though it were an executable, give it input and output file names, and optionally give additional arguments to go directly to the `cowsay` program.
72
+
After rebuilding our container, we can call the `lolcow.sif` as though it were an executable, give it input and output file names.
We are no longer piping redirecting standard output into and out of the container, so we need to bind mount the `/data` directory into the container. It will be convenient to simply set the bind path as an environment variable.
113
83
114
-
$ cat output2
84
+
```
85
+
$ export SINGULARITY_BINDPATH=/data
86
+
87
+
$ ./lolcow.sif /data/input /data/output2
88
+
89
+
$ ./lolcow.sif /data/vader.txt /data/output3
90
+
91
+
$ cat /data/output2 /data/output3
115
92
______________________________________
116
93
/ The grass is always greener over the \
117
94
\ septic tank /
@@ -121,4 +98,27 @@ $ cat output2
121
98
(__)\ )\/\
122
99
||----w |
123
100
|| ||
101
+
__________________
102
+
< I am your father >
103
+
------------------
104
+
\ ^__^
105
+
\ (oo)\_______
106
+
(__)\ )\/\
107
+
||----w |
108
+
|| ||
124
109
```
110
+
111
+
To summarize, we have written a runscript for our container that will do some very basic error checking and expects the location of an input file and an output file allowing it to analyze the data. This is obviously a trivial example, but the sky is the limit. If you can code it, you can make your container do it!
112
+
113
+
---
114
+
**BONUS**
115
+
116
+
You will often see this or something similar as a containers runscript.
0 commit comments