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       NoNewPrivileges=
134           Takes a boolean argument that controls the PR_SET_NO_NEW_PRIVS flag
135           for the container payload. This is equivalent to the
136           --no-new-privileges= command line switch. See systemd-nspawn(1) for
137           details.
138
139       KillSignal=
140           Specify the process signal to send to the container's PID 1 when
141           nspawn itself receives SIGTERM, in order to trigger an orderly
142           shutdown of the container. Defaults to SIGRTMIN+3 if Boot= is used
143           (on systemd-compatible init systems SIGRTMIN+3 triggers an orderly
144           shutdown). For a list of valid signals, see signal(7).
145
146       Personality=
147           Configures the kernel personality for the container. This is
148           equivalent to the --personality= switch.
149
150       MachineID=
151           Configures the 128-bit machine ID (UUID) to pass to the container.
152           This is equivalent to the --uuid= command line switch. This option
153           is privileged (see above).
154
155       PrivateUsers=
156           Configures support for usernamespacing. This is equivalent to the
157           --private-users= command line switch, and takes the same options.
158           This option is privileged (see above). This option is the default
159           if the systemd-nspawn@.service template unit file is used.
160
161       NotifyReady=
162           Configures support for notifications from the container's init
163           process. This is equivalent to the --notify-ready= command line
164           switch, and takes the same parameters. See systemd-nspawn(1) for
165           details about the specific options supported.
166
167       SystemCallFilter=
168           Configures the system call filter applied to containers. This is
169           equivalent to the --system-call-filter= command line switch, and
170           takes the same list parameter. See systemd-nspawn(1) for details.
171
172       LimitCPU=, LimitFSIZE=, LimitDATA=, LimitSTACK=, LimitCORE=, LimitRSS=,
173       LimitNOFILE=, LimitAS=, LimitNPROC=, LimitMEMLOCK=, LimitLOCKS=,
174       LimitSIGPENDING=, LimitMSGQUEUE=, LimitNICE=, LimitRTPRIO=,
175       LimitRTTIME=
176           Configures various types of resource limits applied to containers.
177           This is equivalent to the --rlimit= command line switch, and takes
178           the same arguments. See systemd-nspawn(1) for details.
179
180       OOMScoreAdjust=
181           Configures the OOM score adjustment value. This is equivalent to
182           the --oom-score-adjust= command line switch, and takes the same
183           argument. See systemd-nspawn(1) for details.
184
185       CPUAffinity=
186           Configures the CPU affinity. This is equivalent to the
187           --cpu-affinity= command line switch, and takes the same argument.
188           See systemd-nspawn(1) for details.
189
190       Hostname=
191           Configures the kernel hostname set for the container. This is
192           equivalent to the --hostname= command line switch, and takes the
193           same argument. See systemd-nspawn(1) for details.
194
195       ResolvConf=
196           Configures how /etc/resolv.conf in the container shall be handled.
197           This is equivalent to the --resolv-conf= command line switch, and
198           takes the same argument. See systemd-nspawn(1) for details.
199
200       Timezone=
201           Configures how /etc/localtime in the container shall be handled.
202           This is equivalent to the --timezone= command line switch, and
203           takes the same argument. See systemd-nspawn(1) for details.
204
205       LinkJournal=
206           Configures how to link host and container journal setups. This is
207           equivalent to the --link-journal= command line switch, and takes
208           the same parameter. See systemd-nspawn(1) for details.
209

[FILES] SECTION OPTIONS

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

[NETWORK] SECTION OPTIONS

267       Settings files may include a "[Network]" section, which carries various
268       parameters configuring the network connectivity of the container:
269
270       Private=
271           Takes a boolean argument, which defaults to off. If enabled, the
272           container will run in its own network namespace and not share
273           network interfaces and configuration with the host. This setting
274           corresponds to the --private-network command line switch.
275
276       VirtualEthernet=
277           Takes a boolean argument. Configures whether to create a virtual
278           Ethernet connection ("veth") between host and the container. This
279           setting implies Private=yes. This setting corresponds to the
280           --network-veth command line switch. This option is privileged (see
281           above). This option is the default if the systemd-nspawn@.service
282           template unit file is used.
283
284       VirtualEthernetExtra=
285           Takes a colon-separated pair of interface names. Configures an
286           additional virtual Ethernet connection ("veth") between host and
287           the container. The first specified name is the interface name on
288           the host, the second the interface name in the container. The
289           latter may be omitted in which case it is set to the same name as
290           the host side interface. This setting implies Private=yes. This
291           setting corresponds to the --network-veth-extra= command line
292           switch, and maybe be used multiple times. It is independent of
293           VirtualEthernet=. This option is privileged (see above).
294
295       Interface=
296           Takes a space-separated list of interfaces to add to the container.
297           This option corresponds to the --network-interface= command line
298           switch and implies Private=yes. This option is privileged (see
299           above).
300
301       MACVLAN=, IPVLAN=
302           Takes a space-separated list of interfaces to add MACLVAN or IPVLAN
303           interfaces to, which are then added to the container. These options
304           correspond to the --network-macvlan= and --network-ipvlan= command
305           line switches and imply Private=yes. These options are privileged
306           (see above).
307
308       Bridge=
309           Takes an interface name. This setting implies VirtualEthernet=yes
310           and Private=yes and has the effect that the host side of the
311           created virtual Ethernet link is connected to the specified bridge
312           interface. This option corresponds to the --network-bridge= command
313           line switch. This option is privileged (see above).
314
315       Zone=
316           Takes a network zone name. This setting implies VirtualEthernet=yes
317           and Private=yes and has the effect that the host side of the
318           created virtual Ethernet link is connected to an automatically
319           managed bridge interface named after the passed argument, prefixed
320           with "vz-". This option corresponds to the --network-zone= command
321           line switch. This option is privileged (see above).
322
323       Port=
324           Exposes a TCP or UDP port of the container on the host. This option
325           corresponds to the --port= command line switch, see systemd-
326           nspawn(1) for the precise syntax of the argument this option takes.
327           This option is privileged (see above).
328

SEE ALSO

330       systemd(1), systemd-nspawn(1), systemd.directives(7)
331
332
333
334systemd 245                                                  SYSTEMD.NSPAWN(5)
Impressum