diff --git a/man/systemd.nspawn.xml b/man/systemd.nspawn.xml
index 9ca6d9db2a..f978fef235 100644
--- a/man/systemd.nspawn.xml
+++ b/man/systemd.nspawn.xml
@@ -126,6 +126,16 @@
systemd-nspawn@.service template unit file is used.
+
+ Ephemeral=
+
+ Takes a boolean argument, which defaults to off, If enabled, the container is run with
+ a temporary snapshot of its file system that is removed immediately when the container terminates.
+ This is equivalent to the command line switch. See
+ systemd-nspawn1 for details
+ about the specific options supported.
+
+
ProcessTwo=
diff --git a/src/nspawn/nspawn-gperf.gperf b/src/nspawn/nspawn-gperf.gperf
index 6029686ee9..dec53a06f3 100644
--- a/src/nspawn/nspawn-gperf.gperf
+++ b/src/nspawn/nspawn-gperf.gperf
@@ -19,6 +19,7 @@ struct ConfigPerfItem;
%includes
%%
Exec.Boot, config_parse_boot, 0, 0
+Exec.Ephemeral, config_parse_bool, 0, offsetof(Settings, ephemeral)
Exec.ProcessTwo, config_parse_pid2, 0, 0
Exec.Parameters, config_parse_strv, 0, offsetof(Settings, parameters)
Exec.Environment, config_parse_strv, 0, offsetof(Settings, environment)
diff --git a/src/nspawn/nspawn-settings.h b/src/nspawn/nspawn-settings.h
index d522f3cb36..ba83826bbb 100644
--- a/src/nspawn/nspawn-settings.h
+++ b/src/nspawn/nspawn-settings.h
@@ -84,9 +84,10 @@ typedef enum SettingsMask {
SETTING_RESOLV_CONF = UINT64_C(1) << 21,
SETTING_LINK_JOURNAL = UINT64_C(1) << 22,
SETTING_TIMEZONE = UINT64_C(1) << 23,
- SETTING_RLIMIT_FIRST = UINT64_C(1) << 24, /* we define one bit per resource limit here */
- SETTING_RLIMIT_LAST = UINT64_C(1) << (24 + _RLIMIT_MAX - 1),
- _SETTINGS_MASK_ALL = (UINT64_C(1) << (24 + _RLIMIT_MAX)) -1,
+ SETTING_EPHEMERAL = UINT64_C(1) << 24,
+ SETTING_RLIMIT_FIRST = UINT64_C(1) << 25, /* we define one bit per resource limit here */
+ SETTING_RLIMIT_LAST = UINT64_C(1) << (25 + _RLIMIT_MAX - 1),
+ _SETTINGS_MASK_ALL = (UINT64_C(1) << (25 + _RLIMIT_MAX)) -1,
_SETTING_FORCE_ENUM_WIDTH = UINT64_MAX
} SettingsMask;
@@ -102,6 +103,7 @@ assert_cc(sizeof(SETTING_RLIMIT_LAST) == 8);
typedef struct Settings {
/* [Run] */
StartMode start_mode;
+ bool ephemeral;
char **parameters;
char **environment;
char *user;
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index ca80483205..fb6b603040 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -574,6 +574,7 @@ static int parse_argv(int argc, char *argv[]) {
case 'x':
arg_ephemeral = true;
+ arg_settings_mask |= SETTING_EPHEMERAL;
break;
case 'u':
@@ -3380,6 +3381,9 @@ static int merge_settings(Settings *settings, const char *path) {
strv_free_and_replace(arg_parameters, settings->parameters);
}
+ if ((arg_settings_mask & SETTING_EPHEMERAL) == 0)
+ arg_ephemeral = settings->ephemeral;
+
if ((arg_settings_mask & SETTING_PIVOT_ROOT) == 0 &&
settings->pivot_root_new) {
free_and_replace(arg_pivot_root_new, settings->pivot_root_new);