From dc4d90432bbd209c99fc3f95a127acec37635ce9 Mon Sep 17 00:00:00 2001 From: Tolga Ceylan Date: Wed, 7 Feb 2018 16:48:52 -0800 Subject: [PATCH] fn: memory limit adjustments (#746) 1) limit kernel memory which was previously unlimited, using same limits as user memory for a unified approach. 2) disable swap memory for containers --- api/agent/drivers/docker/docker.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/api/agent/drivers/docker/docker.go b/api/agent/drivers/docker/docker.go index 33dd05958..234f62fd9 100644 --- a/api/agent/drivers/docker/docker.go +++ b/api/agent/drivers/docker/docker.go @@ -134,16 +134,18 @@ func (drv *DockerDriver) Prepare(ctx context.Context, task drivers.ContainerTask container := docker.CreateContainerOptions{ Name: task.Id(), Config: &docker.Config{ - Env: envvars, - Cmd: cmd, - Memory: int64(task.Memory()), - CPUShares: drv.conf.CPUShares, - Hostname: drv.hostname, - Image: task.Image(), - Volumes: map[string]struct{}{}, - OpenStdin: true, - AttachStdin: true, - StdinOnce: true, + Env: envvars, + Cmd: cmd, + Memory: int64(task.Memory()), + MemorySwap: int64(task.Memory()), // disables swap + KernelMemory: int64(task.Memory()), + CPUShares: drv.conf.CPUShares, + Hostname: drv.hostname, + Image: task.Image(), + Volumes: map[string]struct{}{}, + OpenStdin: true, + AttachStdin: true, + StdinOnce: true, }, HostConfig: &docker.HostConfig{}, Context: ctx,