1SYSTEMD.NSPAWN(5)               systemd.nspawn               SYSTEMD.NSPAWN(5)
2
3
4

NAME

6       systemd.nspawn - Container settings
7

SYNOPSIS

9       /etc/systemd/nspawn/machine.nspawn
10
11       /run/systemd/nspawn/machine.nspawn
12
13       /var/lib/machines/machine.nspawn
14

DESCRIPTION

16       An nspawn container settings file (suffix .nspawn) contains runtime
17       configuration for a local container, and is used used by systemd-
18       nspawn(1). Files of this type are named after the containers they
19       define settings for. They are optional, and only required for
20       containers whose execution environment shall differ from the defaults.
21       Files of this type mostly contain settings that may also be set on the
22       systemd-nspawn command line, and make it easier to persistently attach
23       specific settings to specific containers. The syntax of these files is
24       inspired by .desktop files, similarly to other configuration files
25       supported by the systemd project. See systemd.syntax(7) for an
26       overview.
27

.NSPAWN FILE DISCOVERY

29       Files are searched for by appending the .nspawn suffix to the machine
30       name of the container, as specified with the --machine= switch of
31       systemd-nspawn, or derived from the directory or image file name. This
32       file is first searched for in /etc/systemd/nspawn/ and
33       /run/systemd/nspawn/. If found there, the settings are read and all of
34       them take full effect (but may still be overridden by corresponding
35       command line arguments). Otherwise, the file will then be searched for
36       next to the image file or in the immediate parent of the root directory
37       of the container. If the file is found there, only a subset of the
38       settings will take effect however. All settings that possibly elevate
39       privileges or grant additional access to resources of the host (such as
40       files or directories) are ignored. To which options this applies is
41       documented below.
42
43       Persistent settings files created and maintained by the administrator
44       (and thus trusted) should be placed in /etc/systemd/nspawn/, while
45       automatically downloaded (and thus potentially untrusted) settings
46       files are placed in /var/lib/machines/ instead (next to the container
47       images), where their security impact is limited. In order to add
48       privileged settings to .nspawn files acquired from the image vendor, it
49       is recommended to copy the settings files into /etc/systemd/nspawn/ and
50       edit them there, so that the privileged options become available. The
51       precise algorithm for how the files are searched and interpreted may be
52       configured with systemd-nspawn's --settings= switch, see systemd-
53       nspawn(1) for details.
54

[EXEC] SECTION OPTIONS

56       Settings files may include an [Exec] section, which carries various
57       execution parameters:
58
59       Boot=
60           Takes a boolean argument, which defaults to off. If enabled,
61           systemd-nspawn will automatically search for an init executable and
62           invoke it. In this case, the specified parameters using Parameters=
63           are passed as additional arguments to the init process. This
64           setting corresponds to the --boot switch on the systemd-nspawn
65           command line. This option may not be combined with ProcessTwo=yes.
66           This option is specified by default in the systemd-nspawn@.service
67           template unit.
68
69       Ephemeral=
70           Takes a boolean argument, which defaults to off, If enabled, the
71           container is run with a temporary snapshot of its file system that
72           is removed immediately when the container terminates. This is
73           equivalent to the --ephemeral command line switch. See systemd-
74           nspawn(1) for details about the specific options supported.
75
76       ProcessTwo=
77           Takes a boolean argument, which defaults to off. If enabled, the
78           specified program is run as PID 2. A stub init process is run as
79           PID 1. This setting corresponds to the --as-pid2 switch on the
80           systemd-nspawn command line. This option may not be combined with
81           Boot=yes.
82
83       Parameters=
84           Takes a whitespace-separated list of arguments. Single ("'") and
85           double (""") quotes may be used around arguments with whitespace.
86           This is either a command line, beginning with the binary name to
87           execute, or – if Boot= is enabled – the list of arguments to pass
88           to the init process. This setting corresponds to the command line
89           parameters passed on the systemd-nspawn command line.
90
91           Note: Boot=no, Parameters=a b "c c" is the same as systemd-nspawn a
92           b "c c", and Boot=yes, Parameters=b 'c c' is the same as
93           systemd-nspawn --boot b 'c c'.
94
95       Environment=
96           Takes an environment variable assignment consisting of key and
97           value, separated by "=". Sets an environment variable for the main
98           process invoked in the container. This setting may be used multiple
99           times to set multiple environment variables. It corresponds to the
100           --setenv= command line switch.
101
102       User=
103           Takes a UNIX user name. Specifies the user name to invoke the main
104           process of the container as. This user must be known in the
105           container's user database. This corresponds to the --user= command
106           line switch.
107
108       WorkingDirectory=
109           Selects the working directory for the process invoked in the
110           container. Expects an absolute path in the container's file system
111           namespace. This corresponds to the --chdir= command line switch.
112
113       PivotRoot=
114           Selects a directory to pivot to / inside the container when
115           starting up. Takes a single path, or a pair of two paths separated
116           by a colon. Both paths must be absolute, and are resolved in the
117           container's file system namespace. This corresponds to the
118           --pivot-root= command line switch.
119
120       Capability=, DropCapability=
121           Takes a space-separated list of Linux process capabilities (see
122           capabilities(7) for details). The Capability= setting specifies
123           additional capabilities to pass on top of the default set of
124           capabilities. The DropCapability= setting specifies capabilities to
125           drop from the default set. These settings correspond to the
126           --capability= and --drop-capability= command line switches. Note
127           that Capability= is a privileged setting, and only takes effect in
128           .nspawn files in /etc/systemd/nspawn/ and /run/system/nspawn/ (see
129           above). On the other hand, DropCapability= takes effect in all
130           cases. If the special value "all" is passed, all capabilities are
131           retained (or dropped).
132
133           These settings change the bounding set of capabilities which also
134           limits the ambient capabilities as given with the
135           AmbientCapability=.
136
137       AmbientCapability=
138           Takes a space-separated list of Linux process capabilities (see
139           capabilities(7) for details). The AmbientCapability= setting
140           specifies capability which will be passed to to started program in
141           the inheritable and ambient capability sets. This will grant these
142           capabilities to this process. This setting correspond to the
143           --ambient-capability= command line switch.
144
145           The value "all" is not supported for this setting.
146
147           The setting of AmbientCapability= must be covered by the bounding
148           set settings which were established by Capability= and
149           DropCapability=.
150
151           Note that AmbientCapability= is a privileged setting (see above).
152
153       NoNewPrivileges=
154           Takes a boolean argument that controls the PR_SET_NO_NEW_PRIVS flag
155           for the container payload. This is equivalent to the
156           --no-new-privileges= command line switch. See systemd-nspawn(1) for
157           details.
158
159       KillSignal=
160           Specify the process signal to send to the container's PID 1 when
161           nspawn itself receives SIGTERM, in order to trigger an orderly
162           shutdown of the container. Defaults to SIGRTMIN+3 if Boot= is used
163           (on systemd-compatible init systems SIGRTMIN+3 triggers an orderly
164           shutdown). For a list of valid signals, see signal(7).
165
166       Personality=
167           Configures the kernel personality for the container. This is
168           equivalent to the --personality= switch.
169
170       MachineID=
171           Configures the 128-bit machine ID (UUID) to pass to the container.
172           This is equivalent to the --uuid= command line switch. This option
173           is privileged (see above).
174
175       PrivateUsers=
176           Configures support for usernamespacing. This is equivalent to the
177           --private-users= command line switch, and takes the same options.
178           This option is privileged (see above). This option is the default
179           if the systemd-nspawn@.service template unit file is used.
180
181       NotifyReady=
182           Configures support for notifications from the container's init
183           process. This is equivalent to the --notify-ready= command line
184           switch, and takes the same parameters. See systemd-nspawn(1) for
185           details about the specific options supported.
186
187       SystemCallFilter=
188           Configures the system call filter applied to containers. This is
189           equivalent to the --system-call-filter= command line switch, and
190           takes the same list parameter. See systemd-nspawn(1) for details.
191
192       LimitCPU=, LimitFSIZE=, LimitDATA=, LimitSTACK=, LimitCORE=, LimitRSS=,
193       LimitNOFILE=, LimitAS=, LimitNPROC=, LimitMEMLOCK=, LimitLOCKS=,
194       LimitSIGPENDING=, LimitMSGQUEUE=, LimitNICE=, LimitRTPRIO=,
195       LimitRTTIME=
196           Configures various types of resource limits applied to containers.
197           This is equivalent to the --rlimit= command line switch, and takes
198           the same arguments. See systemd-nspawn(1) for details.
199
200       OOMScoreAdjust=
201           Configures the OOM score adjustment value. This is equivalent to
202           the --oom-score-adjust= command line switch, and takes the same
203           argument. See systemd-nspawn(1) for details.
204
205       CPUAffinity=
206           Configures the CPU affinity. This is equivalent to the
207           --cpu-affinity= command line switch, and takes the same argument.
208           See systemd-nspawn(1) for details.
209
210       Hostname=
211           Configures the kernel hostname set for the container. This is
212           equivalent to the --hostname= command line switch, and takes the
213           same argument. See systemd-nspawn(1) for details.
214
215       ResolvConf=
216           Configures how /etc/resolv.conf in the container shall be handled.
217           This is equivalent to the --resolv-conf= command line switch, and
218           takes the same argument. See systemd-nspawn(1) for details.
219
220       Timezone=
221           Configures how /etc/localtime in the container shall be handled.
222           This is equivalent to the --timezone= command line switch, and
223           takes the same argument. See systemd-nspawn(1) for details.
224
225       LinkJournal=
226           Configures how to link host and container journal setups. This is
227           equivalent to the --link-journal= command line switch, and takes
228           the same parameter. See systemd-nspawn(1) for details.
229

[FILES] SECTION OPTIONS

231       Settings files may include a [Files] section, which carries various
232       parameters configuring the file system of the container:
233
234       ReadOnly=
235           Takes a boolean argument, which defaults to off. If specified, the
236           container will be run with a read-only file system. This setting
237           corresponds to the --read-only command line switch.
238
239       Volatile=
240           Takes a boolean argument, or the special value "state". This
241           configures whether to run the container with volatile state and/or
242           configuration. This option is equivalent to --volatile=, see
243           systemd-nspawn(1) for details about the specific options supported.
244
245       Bind=, BindReadOnly=
246           Adds a bind mount from the host into the container. Takes a single
247           path, a pair of two paths separated by a colon, or a triplet of two
248           paths plus an option string separated by colons. This option may be
249           used multiple times to configure multiple bind mounts. This option
250           is equivalent to the command line switches --bind= and --bind-ro=,
251           see systemd-nspawn(1) for details about the specific options
252           supported. This setting is privileged (see above).
253
254       TemporaryFileSystem=
255           Adds a "tmpfs" mount to the container. Takes a path or a pair of
256           path and option string, separated by a colon. This option may be
257           used multiple times to configure multiple "tmpfs" mounts. This
258           option is equivalent to the command line switch --tmpfs=, see
259           systemd-nspawn(1) for details about the specific options supported.
260           This setting is privileged (see above).
261
262       Inaccessible=
263           Masks the specified file or directory in the container, by
264           over-mounting it with an empty file node of the same type with the
265           most restrictive access mode. Takes a file system path as argument.
266           This option may be used multiple times to mask multiple files or
267           directories. This option is equivalent to the command line switch
268           --inaccessible=, see systemd-nspawn(1) for details about the
269           specific options supported. This setting is privileged (see above).
270
271       Overlay=, OverlayReadOnly=
272           Adds an overlay mount point. Takes a colon-separated list of paths.
273           This option may be used multiple times to configure multiple
274           overlay mounts. This option is equivalent to the command line
275           switches --overlay= and --overlay-ro=, see systemd-nspawn(1) for
276           details about the specific options supported. This setting is
277           privileged (see above).
278
279       PrivateUsersChown=
280           Configures whether the ownership of the files and directories in
281           the container tree shall be adjusted to the UID/GID range used, if
282           necessary and user namespacing is enabled. This is equivalent to
283           the --private-users-chown command line switch. This option is
284           privileged (see above).
285

[NETWORK] SECTION OPTIONS

287       Settings files may include a [Network] section, which carries various
288       parameters configuring the network connectivity of the container:
289
290       Private=
291           Takes a boolean argument, which defaults to off. If enabled, the
292           container will run in its own network namespace and not share
293           network interfaces and configuration with the host. This setting
294           corresponds to the --private-network command line switch.
295
296       VirtualEthernet=
297           Takes a boolean argument. Configures whether to create a virtual
298           Ethernet connection ("veth") between host and the container. This
299           setting implies Private=yes. This setting corresponds to the
300           --network-veth command line switch. This option is privileged (see
301           above). This option is the default if the systemd-nspawn@.service
302           template unit file is used.
303
304       VirtualEthernetExtra=
305           Takes a colon-separated pair of interface names. Configures an
306           additional virtual Ethernet connection ("veth") between host and
307           the container. The first specified name is the interface name on
308           the host, the second the interface name in the container. The
309           latter may be omitted in which case it is set to the same name as
310           the host side interface. This setting implies Private=yes. This
311           setting corresponds to the --network-veth-extra= command line
312           switch, and maybe be used multiple times. It is independent of
313           VirtualEthernet=. Note that this option is unrelated to the Bridge=
314           setting below, and thus any connections created this way are not
315           automatically added to any bridge device on the host side. This
316           option is privileged (see above).
317
318       Interface=
319           Takes a space-separated list of interfaces to add to the container.
320           This option corresponds to the --network-interface= command line
321           switch and implies Private=yes. This option is privileged (see
322           above).
323
324       MACVLAN=, IPVLAN=
325           Takes a space-separated list of interfaces to add MACLVAN or IPVLAN
326           interfaces to, which are then added to the container. These options
327           correspond to the --network-macvlan= and --network-ipvlan= command
328           line switches and imply Private=yes. These options are privileged
329           (see above).
330
331       Bridge=
332           Takes an interface name. This setting implies VirtualEthernet=yes
333           and Private=yes and has the effect that the host side of the
334           created virtual Ethernet link is connected to the specified bridge
335           interface. This option corresponds to the --network-bridge= command
336           line switch. This option is privileged (see above).
337
338       Zone=
339           Takes a network zone name. This setting implies VirtualEthernet=yes
340           and Private=yes and has the effect that the host side of the
341           created virtual Ethernet link is connected to an automatically
342           managed bridge interface named after the passed argument, prefixed
343           with "vz-". This option corresponds to the --network-zone= command
344           line switch. This option is privileged (see above).
345
346       Port=
347           Exposes a TCP or UDP port of the container on the host. This option
348           corresponds to the --port= command line switch, see systemd-
349           nspawn(1) for the precise syntax of the argument this option takes.
350           This option is privileged (see above).
351

SEE ALSO

353       systemd(1), systemd-nspawn(1), systemd.directives(7)
354
355
356
357systemd 248                                                  SYSTEMD.NSPAWN(5)
Impressum