Browse code

Merge pull request #14241 from ZJU-SEL/fix-ulimit-usage

Fix ulimit usage of nproc

Sebastiaan van Stijn authored on 2015/07/09 15:23:26
Showing 2 changed files
... ...
@@ -471,6 +471,10 @@ these defaults are not set, `ulimit` settings will be inherited, if not set on
471 471
 `docker run`, from the Docker daemon. Any `--ulimit` options passed to 
472 472
 `docker run` will overwrite these defaults.
473 473
 
474
+Be careful setting `nproc` with the `ulimit` flag as `nproc` is designed by Linux to
475
+set the maximum number of processes available to a user, not to a container. For details
476
+please check the [run](run.md) reference.
477
+
474 478
 ## Miscellaneous options
475 479
 
476 480
 IP masquerading uses address translation to allow containers without a public
... ...
@@ -480,3 +480,19 @@ available in the default container, you can set these using the `--ulimit` flag.
480 480
 
481 481
 The values are sent to the appropriate `syscall` as they are set.
482 482
 Docker doesn't perform any byte conversion. Take this into account when setting the values.
483
+
484
+#### For `nproc` usage:
485
+
486
+Be careful setting `nproc` with the `ulimit` flag as `nproc` is designed by Linux to set the
487
+maximum number of processes available to a user, not to a container.  For example, start four
488
+containers with `daemon` user:
489
+
490
+
491
+    docker run -d -u daemon --ulimit nproc=3 busybox top
492
+    docker run -d -u daemon --ulimit nproc=3 busybox top
493
+    docker run -d -u daemon --ulimit nproc=3 busybox top
494
+    docker run -d -u daemon --ulimit nproc=3 busybox top
495
+
496
+The 4th container fails and reports "[8] System error: resource temporarily unavailable" error. 
497
+This fails because the caller set `nproc=3` resulting in the first three containers using up 
498
+the three processes quota set for the `daemon` user.