Add the memory swappiness tuning option to docker.

Memory swappiness option takes 0-100, and helps to tune swappiness
behavior per container.
For example, When a lower value of swappiness is chosen
the container will see minimum major faults. When no value is
specified for memory-swappiness in docker UI, it is inherited from
parent cgroup. (generally 60 unless it is changed).

Signed-off-by: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
This commit is contained in:
Raghavendra K T 2015-07-12 13:16:33 +05:30 committed by Tibor Vass
parent c88c5588bf
commit b553af956f
5 changed files with 25 additions and 0 deletions

View File

@ -57,6 +57,7 @@ Creates a new container.
--privileged=false Give extended privileges to this container --privileged=false Give extended privileges to this container
--read-only=false Mount the container's root filesystem as read only --read-only=false Mount the container's root filesystem as read only
--restart="no" Restart policy (no, on-failure[:max-retry], always) --restart="no" Restart policy (no, on-failure[:max-retry], always)
--memory-swappiness="" Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
--security-opt=[] Security options --security-opt=[] Security options
-t, --tty=false Allocate a pseudo-TTY -t, --tty=false Allocate a pseudo-TTY
-u, --user="" Username or UID -u, --user="" Username or UID

View File

@ -58,6 +58,7 @@ weight=1
--read-only=false Mount the container's root filesystem as read only --read-only=false Mount the container's root filesystem as read only
--restart="no" Restart policy (no, on-failure[:max-retry], always) --restart="no" Restart policy (no, on-failure[:max-retry], always)
--rm=false Automatically remove the container when it exits --rm=false Automatically remove the container when it exits
--memory-swappiness="" Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
--security-opt=[] Security Options --security-opt=[] Security Options
--sig-proxy=true Proxy received signals to the process --sig-proxy=true Proxy received signals to the process
-t, --tty=false Allocate a pseudo-TTY -t, --tty=false Allocate a pseudo-TTY

View File

@ -514,6 +514,7 @@ container:
--cpu-quota=0: Limit the CPU CFS (Completely Fair Scheduler) quota --cpu-quota=0: Limit the CPU CFS (Completely Fair Scheduler) quota
--blkio-weight=0: Block IO weight (relative weight) accepts a weight value between 10 and 1000. --blkio-weight=0: Block IO weight (relative weight) accepts a weight value between 10 and 1000.
--oom-kill-disable=true|false: Whether to disable OOM Killer for the container or not. --oom-kill-disable=true|false: Whether to disable OOM Killer for the container or not.
--memory-swappiness="": Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
### Memory constraints ### Memory constraints
@ -611,6 +612,20 @@ The following example, illustrates a dangerous way to use the flag:
The container has unlimited memory which can cause the host to run out memory The container has unlimited memory which can cause the host to run out memory
and require killing system processes to free memory. and require killing system processes to free memory.
### Swappiness constraint
By default, a container's kernel can swap out a percentage of anonymous pages.
To set this percentage for a container, specify a `--memory-swappiness` value
between 0 and 100. A value of 0 turns off anonymous page swapping. A value of
100 sets all anonymous pages as swappable.
For example, you can set:
$ docker run -ti --memory-swappiness=0 ubuntu:14.04 /bin/bash
Setting the `--memory-swappiness` option is helpful when you want to retain the
container's working set and to avoid swapping performance penalties.
### CPU share constraint ### CPU share constraint
By default, all containers get the same proportion of CPU cycles. This proportion By default, all containers get the same proportion of CPU cycles. This proportion

View File

@ -48,6 +48,7 @@ docker-create - Create a new container
[**--read-only**[=*false*]] [**--read-only**[=*false*]]
[**--restart**[=*RESTART*]] [**--restart**[=*RESTART*]]
[**--security-opt**[=*[]*]] [**--security-opt**[=*[]*]]
[**--memory-swappiness**[=*MEMORY-SWAPPINESS*]]
[**-t**|**--tty**[=*false*]] [**-t**|**--tty**[=*false*]]
[**-u**|**--user**[=*USER*]] [**-u**|**--user**[=*USER*]]
[**-v**|**--volume**[=*[]*]] [**-v**|**--volume**[=*[]*]]
@ -225,6 +226,9 @@ This value should always larger than **-m**, so you should always use this with
**--security-opt**=[] **--security-opt**=[]
Security Options Security Options
**--memory-swappiness**=""
Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
**-t**, **--tty**=*true*|*false* **-t**, **--tty**=*true*|*false*
Allocate a pseudo-TTY. The default is *false*. Allocate a pseudo-TTY. The default is *false*.

View File

@ -51,6 +51,7 @@ docker-run - Run a command in a new container
[**--rm**[=*false*]] [**--rm**[=*false*]]
[**--security-opt**[=*[]*]] [**--security-opt**[=*[]*]]
[**--sig-proxy**[=*true*]] [**--sig-proxy**[=*true*]]
[**--memory-swappiness**[=*MEMORY-SWAPPINESS*]]
[**-t**|**--tty**[=*false*]] [**-t**|**--tty**[=*false*]]
[**-u**|**--user**[=*USER*]] [**-u**|**--user**[=*USER*]]
[**-v**|**--volume**[=*[]*]] [**-v**|**--volume**[=*[]*]]
@ -371,6 +372,9 @@ its root filesystem mounted as read only prohibiting any writes.
**--sig-proxy**=*true*|*false* **--sig-proxy**=*true*|*false*
Proxy received signals to the process (non-TTY mode only). SIGCHLD, SIGSTOP, and SIGKILL are not proxied. The default is *true*. Proxy received signals to the process (non-TTY mode only). SIGCHLD, SIGSTOP, and SIGKILL are not proxied. The default is *true*.
**--memory-swappiness**=""
Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
**-t**, **--tty**=*true*|*false* **-t**, **--tty**=*true*|*false*
Allocate a pseudo-TTY. The default is *false*. Allocate a pseudo-TTY. The default is *false*.