From 072a643c1d0909bb089c699d15dc3d04f9866525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20=C5=A0trauch?= Date: Mon, 25 Sep 2023 19:46:42 +0200 Subject: [PATCH] Disable oomkiller just for smaller containers --- containers/docker.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/containers/docker.go b/containers/docker.go index 0eacd43..1034679 100644 --- a/containers/docker.go +++ b/containers/docker.go @@ -338,7 +338,10 @@ func (d *Driver) Create(name string, image string, volumePath string, HTTPPort i } } - trueValue := true + OOMKillDisable := false + if memory < 250 { + OOMKillDisable = true + } createdContainer, err := cli.ContainerCreate( context.Background(), @@ -358,7 +361,7 @@ func (d *Driver) Create(name string, image string, volumePath string, HTTPPort i CPUQuota: int64(CPU) * 1000, Memory: int64(memory*110/100) * 1024 * 1024, // Allow 10 % more memory so we have space for MemoryReservation MemoryReservation: int64(memory) * 1024 * 1024, // This should provide softer way how to limit the memory of our containers - OomKillDisable: &trueValue, + OomKillDisable: &OOMKillDisable, }, PortBindings: portBindings, AutoRemove: false,