diff --git a/cmd/dockerd/daemon_unix.go b/cmd/dockerd/daemon_unix.go index 114e9426fd..5fa5f55dae 100644 --- a/cmd/dockerd/daemon_unix.go +++ b/cmd/dockerd/daemon_unix.go @@ -72,7 +72,7 @@ func (cli *DaemonCli) getPlatformRemoteOptions() []libcontainerd.RemoteOption { args := []string{"--systemd-cgroup=true"} opts = append(opts, libcontainerd.WithRuntimeArgs(args)) } - if cli.Config.LiveRestore { + if cli.Config.LiveRestoreEnabled { opts = append(opts, libcontainerd.WithLiveRestore(true)) } opts = append(opts, libcontainerd.WithRuntimePath(daemon.DefaultRuntimeBinary)) diff --git a/daemon/config.go b/daemon/config.go index bf568efefa..a00f338e44 100644 --- a/daemon/config.go +++ b/daemon/config.go @@ -94,7 +94,10 @@ type CommonConfig struct { TrustKeyPath string `json:"-"` CorsHeaders string `json:"api-cors-header,omitempty"` EnableCors bool `json:"api-enable-cors,omitempty"` - LiveRestore bool `json:"live-restore,omitempty"` + + // LiveRestoreEnabled determines whether we should keep containers + // alive upon daemon shutdown/start + LiveRestoreEnabled bool `json:"live-restore,omitempty"` // ClusterStore is the storage backend used for the cluster information. It is used by both // multihost networking (to store networks and endpoints information) and by the node discovery diff --git a/daemon/config_unix.go b/daemon/config_unix.go index 526ec3bd3c..24548a428e 100644 --- a/daemon/config_unix.go +++ b/daemon/config_unix.go @@ -87,7 +87,7 @@ func (config *Config) InstallFlags(cmd *flag.FlagSet, usageFn func(string) strin cmd.StringVar(&config.CgroupParent, []string{"-cgroup-parent"}, "", usageFn("Set parent cgroup for all containers")) cmd.StringVar(&config.RemappedRoot, []string{"-userns-remap"}, "", usageFn("User/Group setting for user namespaces")) cmd.StringVar(&config.ContainerdAddr, []string{"-containerd"}, "", usageFn("Path to containerd socket")) - cmd.BoolVar(&config.LiveRestore, []string{"-live-restore"}, false, usageFn("Enable live restore of docker when containers are still running")) + cmd.BoolVar(&config.LiveRestoreEnabled, []string{"-live-restore"}, false, usageFn("Enable live restore of docker when containers are still running")) config.Runtimes = make(map[string]types.Runtime) cmd.Var(runconfigopts.NewNamedRuntimeOpt("runtimes", &config.Runtimes, stockRuntimeName), []string{"-add-runtime"}, usageFn("Register an additional OCI compatible runtime")) cmd.StringVar(&config.DefaultRuntime, []string{"-default-runtime"}, stockRuntimeName, usageFn("Default OCI runtime for containers")) @@ -133,7 +133,7 @@ func (config *Config) isSwarmCompatible() error { if config.ClusterStore != "" || config.ClusterAdvertise != "" { return fmt.Errorf("--cluster-store and --cluster-advertise daemon configurations are incompatible with swarm mode") } - if config.LiveRestore { + if config.LiveRestoreEnabled { return fmt.Errorf("--live-restore daemon configuration is incompatible with swarm mode") } return nil diff --git a/daemon/daemon.go b/daemon/daemon.go index e44d985cf1..5c3243d8fb 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -658,7 +658,7 @@ func (daemon *Daemon) Shutdown() error { pluginShutdown() - if daemon.configStore.LiveRestore && daemon.containers != nil { + if daemon.configStore.LiveRestoreEnabled && daemon.containers != nil { // check if there are any running containers, if none we should do some cleanup if ls, err := daemon.Containers(&types.ContainerListOptions{}); len(ls) != 0 || err != nil { return nil @@ -916,8 +916,8 @@ func (daemon *Daemon) Reload(config *Config) error { daemon.configStore.Debug = config.Debug } if config.IsValueSet("live-restore") { - daemon.configStore.LiveRestore = config.LiveRestore - if err := daemon.containerdRemote.UpdateOptions(libcontainerd.WithLiveRestore(config.LiveRestore)); err != nil { + daemon.configStore.LiveRestoreEnabled = config.LiveRestoreEnabled + if err := daemon.containerdRemote.UpdateOptions(libcontainerd.WithLiveRestore(config.LiveRestoreEnabled)); err != nil { return err } @@ -1076,7 +1076,7 @@ func (daemon *Daemon) networkOptions(dconfig *Config, activeSandboxes map[string options = append(options, nwconfig.OptionLabels(dconfig.Labels)) options = append(options, driverOptions(dconfig)...) - if daemon.configStore != nil && daemon.configStore.LiveRestore && len(activeSandboxes) != 0 { + if daemon.configStore != nil && daemon.configStore.LiveRestoreEnabled && len(activeSandboxes) != 0 { options = append(options, nwconfig.OptionActiveSandboxes(activeSandboxes)) } diff --git a/daemon/daemon_experimental.go b/daemon/daemon_experimental.go index cad706eb86..a09aeb7062 100644 --- a/daemon/daemon_experimental.go +++ b/daemon/daemon_experimental.go @@ -13,7 +13,7 @@ func (daemon *Daemon) verifyExperimentalContainerSettings(hostConfig *container. } func pluginInit(d *Daemon, cfg *Config, remote libcontainerd.Remote) error { - return plugin.Init(cfg.Root, remote, d.RegistryService, cfg.LiveRestore, d.LogPluginEvent) + return plugin.Init(cfg.Root, remote, d.RegistryService, cfg.LiveRestoreEnabled, d.LogPluginEvent) } func pluginShutdown() {