dockertools: disable MemorySwap on Linux

According to docker docs, setting MemorySwap equals to Memory can
prevent docker containers from using any swap, instead of setting
MemorySwap to zero.
pull/6/head
ohmystack 2018-02-06 16:05:24 +08:00
parent 6775a3252d
commit ecc13c8d86
1 changed files with 2 additions and 1 deletions

View File

@ -104,8 +104,9 @@ func (ds *dockerService) updateCreateConfig(
rOpts := lc.GetResources()
if rOpts != nil {
createConfig.HostConfig.Resources = dockercontainer.Resources{
// Memory and MemorySwap are set to the same value, this prevents containers from using any swap.
Memory: rOpts.MemoryLimitInBytes,
MemorySwap: DefaultMemorySwap(),
MemorySwap: rOpts.MemoryLimitInBytes,
CPUShares: rOpts.CpuShares,
CPUQuota: rOpts.CpuQuota,
CPUPeriod: rOpts.CpuPeriod,