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
@@ -62,13 +63,29 @@ Type "help", "copyright", "credits" or "license" for more information.
62
63
>>>
63
64
```
64
65
66
+
### How does the runscript work?
67
+
Docker has two commands in the `DOCKERFILE` that have something to do with execution, `CMD` and `ENTRYPOINT`. The differences are subtle, but the best description I've found is the following:
68
+
69
+
>> A `CMD` is to provide defaults for an executing container.
70
+
71
+
and
72
+
73
+
>> An `ENTRYPOINT` helps you to configure a container that you can run as an executable.
74
+
75
+
Given the definition, the `ENTRYPOINT` is most appropriate for the Singularity `%runscript`, and so using the default bootstrap (whether from a `docker://` endpoint or a `Singularity` spec file) will set the `ENTRYPOINT` variable as the runscript. You can change this behavior by specifying `IncludeCmd: yes` in the Spec file (see below). If you provide any sort of `%runscript` in your Spec file, this overrides anything provided in Docker. In summary, the order of operations is as follows:
76
+
77
+
1. If a `%runscript` is specified in the `Singularity` spec file, this takes prevalence over all
78
+
2. If no `%runscript` is specified, or if the `import` command is used as in the example above, the `ENTRYPOINT` is used as runscript.
79
+
3. If no `%runscript` is specified, but the user has a `Singularity` spec with `IncludeCmd`, then the Docker `CMD` is used.
80
+
81
+
65
82
### Use a Spec File
66
83
Do a barrel role! Use a spec file! Many times, you want to bootstrap an image, and then either change the `%runscript` or add additional software or commands in the `%post` section. To achieve this, you can create a specification file. Currently, these are distributed with the naming format `[myfile].def`, however (soon) we will use a standard name, `Singularity` so all specification files can be automatically found. Here is what the spec file would look like for tensorflow:
67
84
85
+
68
86
```bash
69
87
Bootstrap: docker
70
88
From: tensorflow/tensorflow:latest
71
-
IncludeCmd: yes
72
89
73
90
%runscript
74
91
@@ -79,7 +96,36 @@ IncludeCmd: yes
79
96
echo"Post install stuffs!"
80
97
```
81
98
82
-
The solution above would be ideal for saving the specification of an image to build at some runtime.
99
+
In the example above, I am overriding any Dockerfile `ENTRYPOINT` because I have defined a `%runscript`. If I want the Dockerfile `ENTRYPOINT` to take preference, I would remove the `%runscript` section:
100
+
101
+
```bash
102
+
Bootstrap: docker
103
+
From: tensorflow/tensorflow:latest
104
+
105
+
%post
106
+
107
+
echo"Post install stuffs!"
108
+
```
109
+
110
+
Note that the spec file above would be (almost) equivalent to the command:
0 commit comments