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

.NSPAWN FILE DISCOVERY

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

[EXEC] SECTION OPTIONS

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

[FILES] SECTION OPTIONS

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

[NETWORK] SECTION OPTIONS

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

SEE ALSO

364       systemd(1), systemd-nspawn(1), systemd.directives(7)
365
366
367
368systemd 251                                                  SYSTEMD.NSPAWN(5)
Impressum