mirror of
https://github.com/moby/moby.git
synced 2025-07-30 18:23:29 +03:00
Merge pull request #41168 from thaJeztah/raise_minimum_memory_limit
Set minimum memory limit to 6M, to account for higher startup memory use
This commit is contained in:
@ -68,8 +68,8 @@ const (
|
|||||||
linuxMinCPUShares = 2
|
linuxMinCPUShares = 2
|
||||||
linuxMaxCPUShares = 262144
|
linuxMaxCPUShares = 262144
|
||||||
platformSupported = true
|
platformSupported = true
|
||||||
// It's not kernel limit, we want this 4M limit to supply a reasonable functional container
|
// It's not kernel limit, we want this 6M limit to account for overhead during startup, and to supply a reasonable functional container
|
||||||
linuxMinMemory = 4194304
|
linuxMinMemory = 6291456
|
||||||
// constants for remapped root settings
|
// constants for remapped root settings
|
||||||
defaultIDSpecifier = "default"
|
defaultIDSpecifier = "default"
|
||||||
defaultRemappedID = "dockremap"
|
defaultRemappedID = "dockremap"
|
||||||
@ -433,7 +433,7 @@ func verifyPlatformContainerResources(resources *containertypes.Resources, sysIn
|
|||||||
|
|
||||||
// memory subsystem checks and adjustments
|
// memory subsystem checks and adjustments
|
||||||
if resources.Memory != 0 && resources.Memory < linuxMinMemory {
|
if resources.Memory != 0 && resources.Memory < linuxMinMemory {
|
||||||
return warnings, fmt.Errorf("Minimum memory limit allowed is 4MB")
|
return warnings, fmt.Errorf("Minimum memory limit allowed is 6MB")
|
||||||
}
|
}
|
||||||
if resources.Memory > 0 && !sysInfo.MemoryLimit {
|
if resources.Memory > 0 && !sysInfo.MemoryLimit {
|
||||||
warnings = append(warnings, "Your kernel does not support memory limit capabilities or the cgroup is not mounted. Limitation discarded.")
|
warnings = append(warnings, "Your kernel does not support memory limit capabilities or the cgroup is not mounted. Limitation discarded.")
|
||||||
|
@ -871,7 +871,7 @@ func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
assert.Assert(c, res.StatusCode != http.StatusOK)
|
assert.Assert(c, res.StatusCode != http.StatusOK)
|
||||||
}
|
}
|
||||||
assert.Assert(c, strings.Contains(string(b), "Minimum memory limit allowed is 4MB"))
|
assert.Assert(c, strings.Contains(string(b), "Minimum memory limit allowed is 6MB"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerSuite) TestContainerAPIRename(c *testing.T) {
|
func (s *DockerSuite) TestContainerAPIRename(c *testing.T) {
|
||||||
|
@ -2826,13 +2826,11 @@ func (s *DockerSuite) TestRunPIDHostWithChildIsKillable(c *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerSuite) TestRunWithTooSmallMemoryLimit(c *testing.T) {
|
func (s *DockerSuite) TestRunWithTooSmallMemoryLimit(c *testing.T) {
|
||||||
// TODO Windows. This may be possible to enable once Windows supports
|
// TODO Windows. This may be possible to enable once Windows supports memory limits on containers
|
||||||
// memory limits on containers
|
|
||||||
testRequires(c, DaemonIsLinux)
|
testRequires(c, DaemonIsLinux)
|
||||||
// this memory limit is 1 byte less than the min, which is 4MB
|
// this memory limit is 1 byte less than the min (daemon.linuxMinMemory), which is 6MB (6291456 bytes)
|
||||||
// https://github.com/docker/docker/blob/v1.5.0/daemon/create.go#L22
|
out, _, err := dockerCmdWithError("create", "-m", "6291455", "busybox")
|
||||||
out, _, err := dockerCmdWithError("run", "-m", "4194303", "busybox")
|
if err == nil || !strings.Contains(out, "Minimum memory limit allowed is 6MB") {
|
||||||
if err == nil || !strings.Contains(out, "Minimum memory limit allowed is 4MB") {
|
|
||||||
c.Fatalf("expected run to fail when using too low a memory limit: %q", out)
|
c.Fatalf("expected run to fail when using too low a memory limit: %q", out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ func (s *DockerSuite) TestUpdateContainerInvalidValue(c *testing.T) {
|
|||||||
dockerCmd(c, "run", "-d", "--name", name, "-m", "300M", "busybox", "true")
|
dockerCmd(c, "run", "-d", "--name", name, "-m", "300M", "busybox", "true")
|
||||||
out, _, err := dockerCmdWithError("update", "-m", "2M", name)
|
out, _, err := dockerCmdWithError("update", "-m", "2M", name)
|
||||||
assert.ErrorContains(c, err, "")
|
assert.ErrorContains(c, err, "")
|
||||||
expected := "Minimum memory limit allowed is 4MB"
|
expected := "Minimum memory limit allowed is 6MB"
|
||||||
assert.Assert(c, strings.Contains(out, expected))
|
assert.Assert(c, strings.Contains(out, expected))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ func (s *DockerSuite) TestDeprecatedStartWithTooLowMemoryLimit(c *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
assert.Equal(c, res.StatusCode, http.StatusBadRequest)
|
assert.Equal(c, res.StatusCode, http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
assert.Assert(c, is.Contains(string(b), "Minimum memory limit allowed is 4MB"))
|
assert.Assert(c, is.Contains(string(b), "Minimum memory limit allowed is 6MB"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// #14640
|
// #14640
|
||||||
|
Reference in New Issue
Block a user