@@ -14,6 +14,43 @@ on when you should set such limits and the possible implications of setting them
14
14
15
15
## Memory
16
16
17
+ ### Understand the risks of running out of memory
18
+
19
+ It is important not to allow a running container to consume too much of the
20
+ host machine's memory. On Linux hosts, if the kernel detects that there is not
21
+ enough memory to perform important system functions, it throws an ` OOME ` , or
22
+ ` Out Of Memory Exception ` , and starts killing processes in order to free up
23
+ memory. Any process is subject to killing, including Docker and other important
24
+ applications. This can effectively bring the entire system down if the wrong
25
+ process is killed.
26
+
27
+ Docker attempts to mitigate these risks by adjusting the OOM priority on the
28
+ Docker daemon so that it will be less likely to be killed than other processes
29
+ on the system. The OOM priority on containers is not adjusted. This makes it more
30
+ likely that an individual container will be killed than that the Docker daemon
31
+ or other system processes will be killed. You should not try to circumvent
32
+ these safeguards by manually setting ` --oom-score-adj ` to an extreme negative
33
+ number on the daemon or a container, or by setting ` --oom-disable-kill ` on a
34
+ container.
35
+
36
+ For more information about the Linux kernel's OOM management, see
37
+ [ Out of Memory Management] ( https://www.kernel.org/doc/gorman/html/understand/understand016.html ) {: target="_ blank" class="_ " }.
38
+
39
+ You can mitigate the risk of system instability due to OOME by:
40
+
41
+ - Perform tests to understand the memory requirements of your application before
42
+ placing it into production.
43
+ - Ensure that your application runs only on hosts with adequate resources.
44
+ - Limit the amount of memory your container can use, as described below.
45
+ - Be mindful when configuring swap on your Docker hosts. Swap is slower and
46
+ less performant than memory but can provide a buffer against running out of
47
+ system memory.
48
+ - Consider converting your container to a [ service] ( /engine/swarm/services.md ) ,
49
+ and using service-level constraints and node labels to ensure that the
50
+ application runs only on hosts with enough memory
51
+
52
+ ### Limit a container's access to memory
53
+
17
54
Docker can enforce hard memory limits, which allow the container to use no more
18
55
than a given amount of user or system memory, or soft limits, which allow the
19
56
container to use as much memory as it needs unless certain conditions are met,
0 commit comments