Skip to content

Commit

Permalink
driver/docker: fix memory swapping
Browse files Browse the repository at this point in the history
MemorySwappiness can only be set in non-Windows options: https://ci.appveyor.com/project/hashicorp/nomad/builds/31832149

Also fixes #6085
  • Loading branch information
Mahmood Ali committed Mar 30, 2020
1 parent a5e16de commit 2def8de
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/docker/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,12 +747,15 @@ func (d *Driver) createContainerConfig(task *drivers.TaskConfig, driverConfig *T

// Windows does not support MemorySwap/MemorySwappiness #2193
if runtime.GOOS == "windows" {
var swapiness int64 = 0

hostConfig.MemorySwap = 0
hostConfig.MemorySwappiness = &swapiness
hostConfig.MemorySwappiness = nil
} else {
hostConfig.MemorySwap = task.Resources.LinuxResources.MemoryLimitBytes // MemorySwap is memory + swap.

// disable swap explicitly in non-Windows environments
var swapiness int64 = 0
hostConfig.MemorySwappiness = &swapiness

}

loggingDriver := driverConfig.Logging.Type
Expand Down

0 comments on commit 2def8de

Please sign in to comment.