Skip to content

Commit a173c46

Browse files
author
Misty Stanley-Jones
authored
Document OOME information (docker#3536)
1 parent 2d70554 commit a173c46

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

compose/compose-file/index.md

+10
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,16 @@ services:
347347
memory: 20M
348348
```
349349

350+
##### Out Of Memory Exceptions (OOME)
351+
352+
If your services or containers attempt to use more memory than the system has
353+
available, you may experience an Out Of Memory Exception (OOME) and a container,
354+
or the Docker daemon, might be killed by the kernel OOM killer. To prevent this
355+
from happening, ensure that your application runs on hosts with adequate memory
356+
and see [Understand the risks of running out of
357+
memory](/engine/admin/resource_constraints.md#understand-the-risks-of-running-out-of-memory).
358+
359+
350360
#### restart_policy
351361

352362
Configures if and how to restart containers when they exit. Replaces

engine/admin/index.md

+9
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ non-responsive, you can also
8484
threads to be added to the daemon log by sending the `SIGUSR` signal to the
8585
Docker daemon.
8686

87+
### Out Of Memory Exceptions (OOME)
88+
89+
If your containers attempt to use more memory than the system has available,
90+
you may experience an Out Of Memory Exception (OOME) and a container, or the
91+
Docker daemon, might be killed by the kernel OOM killer. To prevent this from
92+
happening, ensure that your application runs on hosts with adequate memory and
93+
see
94+
[Understand the risks of running out of memory](/engine/admin/resource_constraints.md#understand-the-risks-of-running-out-of-memory).
95+
8796
### Read the logs
8897

8998
The daemon logs may help you diagnose problems. The logs may be saved in one of

engine/admin/resource_constraints.md

+37
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,43 @@ on when you should set such limits and the possible implications of setting them
1414

1515
## Memory
1616

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+
1754
Docker can enforce hard memory limits, which allow the container to use no more
1855
than a given amount of user or system memory, or soft limits, which allow the
1956
container to use as much memory as it needs unless certain conditions are met,

engine/swarm/services.md

+12
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,18 @@ the requirement (for instance, if you request 4 CPUs and no node in the swarm
522522
has 4 CPUs), the service remains in a pending state until a node is available to
523523
run its tasks.
524524

525+
#### Out Of Memory Exceptions (OOME)
526+
527+
If your service attempts to use more memory than the swarm node has available,
528+
you may experience an Out Of Memory Exception (OOME) and a container, or the
529+
Docker daemon, might be killed by the kernel OOM killer. To prevent this from
530+
happening. ensure that your application runs on hosts with adequate memory and
531+
see
532+
[Understand the risks of running out of memory](/engine/admin/resource_constraints.md#understand-the-risks-of-running-out-of-memory).
533+
534+
Swarm services allow you to use resource constraints, placement preferences, and
535+
labels to ensure that your service is deployed to the appropriate swarm nodes.
536+
525537
### Specify service placement preferences (--placement-pref)
526538

527539
{% include edge_only.md section="feature" %}

0 commit comments

Comments
 (0)