diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index a09076a4a4..b30b2dafc0 100755 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -265,6 +265,10 @@ func verifyContainerResources(resources *runconfig.Resources) ([]string, error) warnings = append(warnings, "You specified a kernel memory limit on a kernel older than 4.0. Kernel memory limits are experimental on older kernels, it won't work as expected and can cause your system to be unstable.") logrus.Warnf("You specified a kernel memory limit on a kernel older than 4.0. Kernel memory limits are experimental on older kernels, it won't work as expected and can cause your system to be unstable.") } + if resources.OomKillDisable && !sysInfo.OomKillDisable { + resources.OomKillDisable = false + return warnings, fmt.Errorf("Your kernel does not support oom kill disable.") + } // cpu subsystem checks and adjustments if resources.CPUShares > 0 && !sysInfo.CPUShares { @@ -364,10 +368,6 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *runconfig.HostC return warnings, fmt.Errorf("SHM size must be greater then 0") } - if hostConfig.OomKillDisable && !sysInfo.OomKillDisable { - hostConfig.OomKillDisable = false - return warnings, fmt.Errorf("Your kernel does not support oom kill disable.") - } if hostConfig.OomScoreAdj < -1000 || hostConfig.OomScoreAdj > 1000 { return warnings, fmt.Errorf("Invalid value %d, range for oom score adj is [-1000, 1000].", hostConfig.OomScoreAdj) } diff --git a/runconfig/hostconfig.go b/runconfig/hostconfig.go index 20088c0bf1..98d044cf66 100644 --- a/runconfig/hostconfig.go +++ b/runconfig/hostconfig.go @@ -188,6 +188,7 @@ type Resources struct { MemoryReservation int64 // Memory soft limit (in bytes) MemorySwap int64 // Total memory usage (memory + swap); set `-1` to disable swap MemorySwappiness *int64 // Tuning container memory swappiness behaviour + OomKillDisable bool // Whether to disable OOM Killer or not Ulimits []*ulimit.Ulimit // List of ulimits to be set in the container } @@ -216,7 +217,6 @@ type HostConfig struct { IpcMode IpcMode // IPC namespace to use for the container Links []string // List of links (in the name:alias form) OomScoreAdj int // Container preference for OOM-killing - OomKillDisable bool // Whether to disable OOM Killer or not PidMode PidMode // PID namespace to use for the container Privileged bool // Is the container in privileged mode PublishAllPorts bool // Should docker publish all exposed port for the container diff --git a/runconfig/parse.go b/runconfig/parse.go index e834112c57..7765d1bcc7 100644 --- a/runconfig/parse.go +++ b/runconfig/parse.go @@ -353,6 +353,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe MemorySwap: memorySwap, MemorySwappiness: flSwappiness, KernelMemory: KernelMemory, + OomKillDisable: *flOomKillDisable, CPUShares: *flCPUShares, CPUPeriod: *flCPUPeriod, CpusetCpus: *flCpusetCpus, @@ -397,7 +398,6 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe Binds: binds, ContainerIDFile: *flContainerIDFile, OomScoreAdj: *flOomScoreAdj, - OomKillDisable: *flOomKillDisable, Privileged: *flPrivileged, PortBindings: portBindings, Links: flLinks.GetAll(),