mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Set default MemorySwap on Docker side
As discussed in docker/libcontainer#616, we should move this behavior to Docker side. Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
parent
b58565e9d6
commit
7e0dfbf4cd
3 changed files with 15 additions and 0 deletions
|
@ -19,6 +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")
|
return "", nil, fmt.Errorf("Config cannot be empty in order to create a container")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
daemon.adaptContainerSettings(hostConfig)
|
||||||
warnings, err := daemon.verifyContainerSettings(hostConfig, config)
|
warnings, err := daemon.verifyContainerSettings(hostConfig, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", warnings, err
|
return "", warnings, err
|
||||||
|
|
|
@ -114,6 +114,16 @@ func checkKernel() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (daemon *Daemon) adaptContainerSettings(hostConfig *runconfig.HostConfig) {
|
||||||
|
if hostConfig == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if hostConfig.Memory > 0 && hostConfig.MemorySwap == 0 {
|
||||||
|
// By default, MemorySwap is set to twice the size of Memory.
|
||||||
|
hostConfig.MemorySwap = hostConfig.Memory * 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig, config *runconfig.Config) ([]string, error) {
|
func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig, config *runconfig.Config) ([]string, error) {
|
||||||
var warnings []string
|
var warnings []string
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,10 @@ func checkKernel() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (daemon *Daemon) adaptContainerSettings(hostConfig *runconfig.HostConfig) {
|
||||||
|
// TODO Windows.
|
||||||
|
}
|
||||||
|
|
||||||
func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig, config *runconfig.Config) ([]string, error) {
|
func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig, config *runconfig.Config) ([]string, error) {
|
||||||
// TODO Windows. Verifications TBC
|
// TODO Windows. Verifications TBC
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
Loading…
Reference in a new issue