mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #13834 from hqhq/hq_memswap_change
Set default MemorySwap on Docker side
This commit is contained in:
commit
6e1d887722
3 changed files with 15 additions and 0 deletions
|
@ -20,6 +20,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")
|
||||
}
|
||||
|
||||
daemon.adaptContainerSettings(hostConfig)
|
||||
warnings, err := daemon.verifyContainerSettings(hostConfig, config)
|
||||
if err != nil {
|
||||
return "", warnings, err
|
||||
|
|
|
@ -117,6 +117,16 @@ func checkKernel() error {
|
|||
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) {
|
||||
var warnings []string
|
||||
|
||||
|
|
|
@ -73,6 +73,10 @@ func checkKernel() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (daemon *Daemon) adaptContainerSettings(hostConfig *runconfig.HostConfig) {
|
||||
// TODO Windows.
|
||||
}
|
||||
|
||||
func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig, config *runconfig.Config) ([]string, error) {
|
||||
// TODO Windows. Verifications TBC
|
||||
return nil, nil
|
||||
|
|
Loading…
Add table
Reference in a new issue