diff --git a/api/server/router/container/container_routes.go b/api/server/router/container/container_routes.go index c1f32724ee..836f2b1727 100644 --- a/api/server/router/container/container_routes.go +++ b/api/server/router/container/container_routes.go @@ -475,6 +475,12 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo } } + // When using API 1.39 and under, KernelMemoryTCP should be ignored because it + // was added in API 1.40. + if hostConfig != nil && versions.LessThan(version, "1.40") { + hostConfig.KernelMemoryTCP = 0 + } + ccr, err := s.backend.ContainerCreate(types.ContainerCreateConfig{ Name: name, Config: config, diff --git a/integration/container/run_linux_test.go b/integration/container/run_linux_test.go index 6a2a647c21..e9d816b81f 100644 --- a/integration/container/run_linux_test.go +++ b/integration/container/run_linux_test.go @@ -8,6 +8,7 @@ import ( "time" containertypes "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/internal/test/request" "gotest.tools/assert" @@ -18,6 +19,7 @@ import ( func TestKernelTCPMemory(t *testing.T) { skip.If(t, testEnv.DaemonInfo.OSType != "linux") + skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.40"), "skip test from new feature") skip.If(t, !testEnv.DaemonInfo.KernelMemoryTCP) defer setupTest(t)()