diff --git a/daemon/container.go b/daemon/container.go index fbf4613a9d..713682a986 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -252,7 +252,6 @@ func (container *Container) Start() (err error) { if err := container.initializeNetworking(); err != nil { return err } - container.verifyDaemonSettings() linkedEnv, err := container.setupLinkedContainers() if err != nil { return err diff --git a/daemon/container_linux.go b/daemon/container_linux.go index 9df53a09be..b12e27923b 100644 --- a/daemon/container_linux.go +++ b/daemon/container_linux.go @@ -832,21 +832,6 @@ func (container *Container) initializeNetworking() error { return container.buildHostnameFile() } -// Make sure the config is compatible with the current kernel -func (container *Container) verifyDaemonSettings() { - if container.hostConfig.Memory > 0 && !container.daemon.sysInfo.MemoryLimit { - logrus.Warnf("Your kernel does not support memory limit capabilities. Limitation discarded.") - container.hostConfig.Memory = 0 - } - if container.hostConfig.Memory > 0 && container.hostConfig.MemorySwap != -1 && !container.daemon.sysInfo.SwapLimit { - logrus.Warnf("Your kernel does not support swap limit capabilities. Limitation discarded.") - container.hostConfig.MemorySwap = -1 - } - if container.daemon.sysInfo.IPv4ForwardingDisabled { - logrus.Warnf("IPv4 forwarding is disabled. Networking will not work") - } -} - func (container *Container) ExportRw() (archive.Archive, error) { if container.daemon == nil { return nil, fmt.Errorf("Can't load storage driver for unregistered container %s", container.ID) diff --git a/daemon/container_windows.go b/daemon/container_windows.go index 0807aabc93..8bbbf65bfb 100644 --- a/daemon/container_windows.go +++ b/daemon/container_windows.go @@ -59,9 +59,6 @@ func (container *Container) setupWorkingDirectory() error { return nil } -func (container *Container) verifyDaemonSettings() { -} - func populateCommand(c *Container, env []string) error { en := &execdriver.Network{ Mtu: c.daemon.config.Mtu, diff --git a/daemon/create.go b/daemon/create.go index 031f337a94..8f8c946aec 100644 --- a/daemon/create.go +++ b/daemon/create.go @@ -19,7 +19,7 @@ func (daemon *Daemon) ContainerCreate(name string, config *runconfig.Config, hos return "", nil, fmt.Errorf("Config cannot be empty in order to create a container") } - warnings, err := daemon.verifyHostConfig(hostConfig) + warnings, err := daemon.verifyContainerSettings(hostConfig) if err != nil { return "", warnings, err } diff --git a/daemon/daemon.go b/daemon/daemon.go index 14ea47a6a2..7356cfde69 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -1166,7 +1166,7 @@ func checkKernel() error { return nil } -func (daemon *Daemon) verifyHostConfig(hostConfig *runconfig.HostConfig) ([]string, error) { +func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig) ([]string, error) { var warnings []string if hostConfig == nil { @@ -1181,10 +1181,12 @@ func (daemon *Daemon) verifyHostConfig(hostConfig *runconfig.HostConfig) ([]stri } if hostConfig.Memory > 0 && !daemon.SystemConfig().MemoryLimit { warnings = append(warnings, "Your kernel does not support memory limit capabilities. Limitation discarded.") + logrus.Warnf("Your kernel does not support memory limit capabilities. Limitation discarded.") hostConfig.Memory = 0 } if hostConfig.Memory > 0 && hostConfig.MemorySwap != -1 && !daemon.SystemConfig().SwapLimit { warnings = append(warnings, "Your kernel does not support swap limit capabilities, memory limited without swap.") + logrus.Warnf("Your kernel does not support swap limit capabilities, memory limited without swap.") hostConfig.MemorySwap = -1 } if hostConfig.Memory > 0 && hostConfig.MemorySwap > 0 && hostConfig.MemorySwap < hostConfig.Memory { @@ -1195,10 +1197,12 @@ func (daemon *Daemon) verifyHostConfig(hostConfig *runconfig.HostConfig) ([]stri } if hostConfig.CpuPeriod > 0 && !daemon.SystemConfig().CpuCfsPeriod { warnings = append(warnings, "Your kernel does not support CPU cfs period. Period discarded.") + logrus.Warnf("Your kernel does not support CPU cfs period. Period discarded.") hostConfig.CpuPeriod = 0 } if hostConfig.CpuQuota > 0 && !daemon.SystemConfig().CpuCfsQuota { warnings = append(warnings, "Your kernel does not support CPU cfs quota. Quota discarded.") + logrus.Warnf("Your kernel does not support CPU cfs quota. Quota discarded.") hostConfig.CpuQuota = 0 } if hostConfig.BlkioWeight > 0 && (hostConfig.BlkioWeight < 10 || hostConfig.BlkioWeight > 1000) { @@ -1208,7 +1212,10 @@ func (daemon *Daemon) verifyHostConfig(hostConfig *runconfig.HostConfig) ([]stri hostConfig.OomKillDisable = false return warnings, fmt.Errorf("Your kernel does not support oom kill disable.") } - + if daemon.SystemConfig().IPv4ForwardingDisabled { + warnings = append(warnings, "IPv4 forwarding is disabled. Networking will not work.") + logrus.Warnf("IPv4 forwarding is disabled. Networking will not work") + } return warnings, nil } diff --git a/daemon/start.go b/daemon/start.go index 057f27fa52..7d37a9f5e4 100644 --- a/daemon/start.go +++ b/daemon/start.go @@ -20,7 +20,7 @@ func (daemon *Daemon) ContainerStart(name string, hostConfig *runconfig.HostConf return fmt.Errorf("Container already started") } - if _, err = daemon.verifyHostConfig(hostConfig); err != nil { + if _, err = daemon.verifyContainerSettings(hostConfig); err != nil { return err }