What does `--oom-kill-disable` do for a Docker container? : <p>I have understood that <code>docker run -m 256m --memory-swap 256m</code> will limit a container so that it can use at most 256 MB of memory and no swap. If it allocates more, then a process in the container (not "the container") will be killed. For example:</p>

<pre><code>$ sudo docker run -it --rm -m 256m --memory-swap 256m \
        stress --vm 1 --vm-bytes 2000M --vm-hang 0
stress: info: [1] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd
stress: FAIL: [1] (415) &lt;-- worker 7 got signal 9
stress: WARN: [1] (417) now reaping child worker processes
stress: FAIL: [1] (421) kill error: No such process
stress: FAIL: [1] (451) failed run completed in 1s
</code></pre>

<p>Apparently one of the workers allocates more memory than is allowed and receives a <code>SIGKILL</code>. Note that the parent process stays alive.</p>

<p>Now if the effect of <code>-m</code> is to invoke the OOM killer if a process allocates too much memory, then what happens when specifying <code>-m</code> <em>and</em> <code>--oom-kill-disable</code>? Trying it like above has the following result:</p>

<pre><code>$ sudo docker run -it --rm -m 256m --memory-swap 256m --oom-kill-disable \
        stress --vm 1 --vm-bytes 2000M --vm-hang 0
stress: info: [1] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd
(waits here)
</code></pre>

<p>In a different shell:</p>

<pre><code>$ docker stats
CONTAINER           CPU %               MEM USAGE / LIMIT       MEM %               NET I/O             BLOCK I/O           PIDS
f5e4c30d75c9        0.00%               256 MiB / 256 MiB       100.00%             0 B / 508 B         0 B / 0 B           2


$ top
  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                           
19391 root      20   0 2055904 262352    340 D   0.0  0.1   0:00.05 stress
</code></pre>

<p>I see the <code>docker stats</code> shows a memory consumption of 256 MB, and <code>top</code> shows a <code>RES</code> of 256 MB and a <code>VIRT</code> of 2000 MB. But, what does that actually mean? What will happen to a process inside the container that tries to use more memory than allowed? In which sense it is constrained by <code>-m</code>?</p>
