diff --git a/api/handlers.go b/api/handlers.go index aff7529e0e..e2dfee0462 100644 --- a/api/handlers.go +++ b/api/handlers.go @@ -414,8 +414,12 @@ func getContainerJSON(c *context, w http.ResponseWriter, r *http.Request) { func postContainersCreate(c *context, w http.ResponseWriter, r *http.Request) { r.ParseForm() var ( - config dockerclient.ContainerConfig - name = r.Form.Get("name") + config = dockerclient.ContainerConfig{ + HostConfig: dockerclient.HostConfig{ + MemorySwappiness: -1, + }, + } + name = r.Form.Get("name") ) if err := json.NewDecoder(r.Body).Decode(&config); err != nil { diff --git a/test/integration/compose/up.bats b/test/integration/compose/up.bats index 27e9c1184b..8b49bd35a3 100644 --- a/test/integration/compose/up.bats +++ b/test/integration/compose/up.bats @@ -18,4 +18,17 @@ function teardown() { [ "${#lines[@]}" -eq 2 ] } +@test "docker-compose up - check memory swappiness" { + start_docker_with_busybox 2 + swarm_manage + FILE=$TESTDATA/compose/simple.yml + docker-compose_swarm -f $FILE up -d + + run docker_swarm ps -q + [ "${#lines[@]}" -eq 2 ] + + run docker_swarm inspect compose_service1_1 + # check memory-swappiness + [[ "${output}" == *"\"MemorySwappiness\": -1"* ]] +}