1singularity(1)                                                  singularity(1)
2
3
4

NAME

6       singularity-build - Build a Singularity image
7
8
9

SYNOPSIS

11       singularity build [local options...] <IMAGE PATH> <BUILD SPEC>
12
13
14

DESCRIPTION

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

OPTIONS

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       -F, --force[=false]
96           delete and overwrite an image if it currently exists
97
98
99       -h, --help[=false]
100           help for build
101
102
103       --json[=false]
104           interpret build definition as JSON
105
106
107       --library=" ⟨https://library.sylabs.io"⟩
108           container Library URL
109
110
111       --no-cleanup[=false]
112           do NOT clean up bundle after failed build, can be helpul for
113       debugging
114
115
116       --nohttps[=false]
117           do NOT use HTTPS, for communicating with local docker registry
118
119
120       -T, --notest[=false]
121           build without running tests in %test section
122
123
124       --passphrase[=false]
125           Enter a passphrase for an encrypted contaner
126
127
128       --pem-path=""
129           Enter an path to a PEM formated RSA key for an encrypted container
130
131
132       -r, --remote[=false]
133           build image remotely (does not require root)
134
135
136       -s, --sandbox[=false]
137           build image as sandbox format (chroot directory structure)
138
139
140       --section=[all]
141           only run specific section(s) of deffile (setup, post, files,
142       environment, test, labels, none)
143
144
145       --tmpdir=""
146           specify a temporary directory to use for build
147
148
149       -u, --update[=false]
150           run definition over existing container (skips header)
151
152
153

EXAMPLE

155                DEF FILE BASE OS:
156
157                    Library:
158                        Bootstrap: library
159                        From: debian:9
160
161                    Docker:
162                        Bootstrap: docker
163                        From: tensorflow/tensorflow:latest
164                        IncludeCmd: yes # Use the CMD as runscript instead of ENTRYPOINT
165
166                    Singularity Hub:
167                        Bootstrap: shub
168                        From: singularityhub/centos
169
170                    YUM/RHEL:
171                        Bootstrap: yum
172                        OSVersion: 7
173                        MirrorURL: http://mirror.centos.org/centos-%{OSVERSION}/%{OSVERSION}/os/x86_64/
174                        Include: yum
175
176                    Debian/Ubuntu:
177                        Bootstrap: debootstrap
178                        OSVersion: trusty
179                        MirrorURL: http://us.archive.ubuntu.com/ubuntu/
180
181                    Local Image:
182                        Bootstrap: localimage
183                        From: /home/dave/starter.img
184
185                    Scratch:
186                        Bootstrap: scratch # Populate the container with a minimal rootfs in %setup
187
188                DEFFILE SECTIONS:
189
190                    %pre
191                        echo "This is a scriptlet that will be executed on the host, as root before"
192                        echo "the container has been bootstrapped. This section is not commonly used."
193
194                    %setup
195                        echo "This is a scriptlet that will be executed on the host, as root, after"
196                        echo "the container has been bootstrapped. To install things into the container"
197                        echo "reference the file system location with $SINGULARITY_ROOTFS."
198
199                    %post
200                        echo "This scriptlet section will be executed from within the container after"
201                        echo "the bootstrap/base has been created and setup."
202
203                    %test
204                        echo "Define any test commands that should be executed after container has been"
205                        echo "built. This scriptlet will be executed from within the running container"
206                        echo "as the root user. Pay attention to the exit/return value of this scriptlet"
207                        echo "as any non-zero exit code will be assumed as failure."
208                        exit 0
209
210                    %runscript
211                        echo "Define actions for the container to be executed with the run command or"
212                        echo "when container is executed."
213
214                    %startscript
215                        echo "Define actions for container to perform when started as an instance."
216
217                    %labels
218                        HELLO MOTO
219                        KEY VALUE
220
221                    %files
222                        /path/on/host/file.txt /path/on/container/file.txt
223                        relative_file.txt /path/on/container/relative_file.txt
224
225                    %environment
226                        LUKE=goodguy
227                        VADER=badguy
228                        HAN=someguy
229                        export HAN VADER LUKE
230
231                    %help
232                        This is a text file to be displayed with the run-help command.
233
234                COMMANDS:
235
236                    Build a sif file from a Singularity recipe file:
237                        $ singularity build /tmp/debian0.sif /path/to/debian.def
238
239                    Build a sif image from the Library:
240                        $ singularity build /tmp/debian1.sif library://debian:latest
241
242                    Build a base sandbox from DockerHub, make changes to it, then build sif
243                        $ singularity build --sandbox /tmp/debian docker://debian:latest
244                        $ singularity exec --writable /tmp/debian apt-get install python
245                        $ singularity build /tmp/debian2.sif /tmp/debian
246
247
248
249

SEE ALSO

251       singularity(1)
252
253
254

HISTORY

256       21-Oct-2019 Auto generated by spf13/cobra
257
258
259
260Auto generated by spf13/cobra      Oct 2019                     singularity(1)
Impressum