1singularity(1) singularity(1)
2
3
4
6 singularity-build - Build a Singularity image
7
8
9
11 singularity build [local options...] <IMAGE PATH> <BUILD SPEC>
12
13
14
16 IMAGE PATH:
17
18
19 When Singularity builds the container, output can be one of a few
20 formats:
21
22
23 default: The compressed Singularity read only image format (default)
24 sandbox: This is a read-write container within a directory structure
25
26
27
28 note: It is a common workflow to use the "sandbox" mode for development
29 of the
30 container, and then build it as a default Singularity image for
31 production
32 use. The default format is immutable.
33
34
35 BUILD SPEC:
36
37
38 The build spec target is a definition (def) file, local image, or URI
39 that can
40 be used to create a Singularity container. Several different local
41 target
42 formats exist:
43
44
45 def file : This is a recipe for building a container (examples below)
46 directory: A directory structure containing a (ch)root file system
47 image: A local image on your machine (will convert to sif if
48 it is legacy format)
49
50
51
52 Targets can also be remote and defined by a URI of the following
53 formats:
54
55
56 library:// an image library (default https://cloud.sylabs.io/library)
57 docker:// a Docker registry (default Docker Hub)
58 shub:// a Singularity registry (default Singularity Hub)
59 oras:// a supporting OCI registry
60
61
62
63
65 --arch="amd64"
66 architecture for remote build
67
68
69 --builder=" ⟨https://build.sylabs.io"⟩
70 remote Build Service URL, setting this implies --remote
71
72
73 -d, --detached[=false]
74 submit build job and print build ID (no real-time logs and requires
75 --remote)
76
77
78 --disable-cache[=false]
79 do not use cache or create cache
80
81
82 --docker-login[=false]
83 login to a Docker Repository interactively
84
85
86 -e, --encrypt[=false]
87 build an image with an encrypted file system
88
89
90 -f, --fakeroot[=false]
91 build using user namespace to fake root user (requires a privileged
92 installation)
93
94
95 --fix-perms[=false]
96 ensure owner has rwX permissions on all container content for
97 oci/docker sources
98
99
100 -F, --force[=false]
101 overwrite an image file if it exists
102
103
104 -h, --help[=false]
105 help for build
106
107
108 --json[=false]
109 interpret build definition as JSON
110
111
112 --library=" ⟨https://library.sylabs.io"⟩
113 container Library URL
114
115
116 --no-cleanup[=false]
117 do NOT clean up bundle after failed build, can be helpul for
118 debugging
119
120
121 --nohttps[=false]
122 do NOT use HTTPS with the docker:// transport (useful for local
123 docker registries without a certificate)
124
125
126 -T, --notest[=false]
127 build without running tests in %test section
128
129
130 --passphrase[=false]
131 prompt for an encryption passphrase
132
133
134 --pem-path=""
135 enter an path to a PEM formated RSA key for an encrypted container
136
137
138 -r, --remote[=false]
139 build image remotely (does not require root)
140
141
142 -s, --sandbox[=false]
143 build image as sandbox format (chroot directory structure)
144
145
146 --section=[all]
147 only run specific section(s) of deffile (setup, post, files,
148 environment, test, labels, none)
149
150
151 -u, --update[=false]
152 run definition over existing container (skips header)
153
154
155
157 DEF FILE BASE OS:
158
159 Library:
160 Bootstrap: library
161 From: debian:9
162
163 Docker:
164 Bootstrap: docker
165 From: tensorflow/tensorflow:latest
166 IncludeCmd: yes # Use the CMD as runscript instead of ENTRYPOINT
167
168 Singularity Hub:
169 Bootstrap: shub
170 From: singularityhub/centos
171
172 YUM/RHEL:
173 Bootstrap: yum
174 OSVersion: 7
175 MirrorURL: http://mirror.centos.org/centos-%{OSVERSION}/%{OSVERSION}/os/x86_64/
176 Include: yum
177
178 Debian/Ubuntu:
179 Bootstrap: debootstrap
180 OSVersion: trusty
181 MirrorURL: http://us.archive.ubuntu.com/ubuntu/
182
183 Local Image:
184 Bootstrap: localimage
185 From: /home/dave/starter.img
186
187 Scratch:
188 Bootstrap: scratch # Populate the container with a minimal rootfs in %setup
189
190 DEFFILE SECTIONS:
191
192 %pre
193 echo "This is a scriptlet that will be executed on the host, as root before"
194 echo "the container has been bootstrapped. This section is not commonly used."
195
196 %setup
197 echo "This is a scriptlet that will be executed on the host, as root, after"
198 echo "the container has been bootstrapped. To install things into the container"
199 echo "reference the file system location with $SINGULARITY_ROOTFS."
200
201 %post
202 echo "This scriptlet section will be executed from within the container after"
203 echo "the bootstrap/base has been created and setup."
204
205 %test
206 echo "Define any test commands that should be executed after container has been"
207 echo "built. This scriptlet will be executed from within the running container"
208 echo "as the root user. Pay attention to the exit/return value of this scriptlet"
209 echo "as any non-zero exit code will be assumed as failure."
210 exit 0
211
212 %runscript
213 echo "Define actions for the container to be executed with the run command or"
214 echo "when container is executed."
215
216 %startscript
217 echo "Define actions for container to perform when started as an instance."
218
219 %labels
220 HELLO MOTO
221 KEY VALUE
222
223 %files
224 /path/on/host/file.txt /path/on/container/file.txt
225 relative_file.txt /path/on/container/relative_file.txt
226
227 %environment
228 LUKE=goodguy
229 VADER=badguy
230 HAN=someguy
231 export HAN VADER LUKE
232
233 %help
234 This is a text file to be displayed with the run-help command.
235
236 COMMANDS:
237
238 Build a sif file from a Singularity recipe file:
239 $ singularity build /tmp/debian0.sif /path/to/debian.def
240
241 Build a sif image from the Library:
242 $ singularity build /tmp/debian1.sif library://debian:latest
243
244 Build a base sandbox from DockerHub, make changes to it, then build sif
245 $ singularity build --sandbox /tmp/debian docker://debian:latest
246 $ singularity exec --writable /tmp/debian apt-get install python
247 $ singularity build /tmp/debian2.sif /tmp/debian
248
249
250
251
253 singularity(1)
254
255
256
258 18-Feb-2020 Auto generated by spf13/cobra
259
260
261
262Auto generated by spf13/cobra Feb 2020 singularity(1)