Browse code

Clarify that nproc is not for per container

Fix ulimit nproc spec in daemon

Signed-off-by: Harry Zhang <harryzhang@zju.edu.cn>

Harry Zhang authored on 2015/06/28 23:40:53
Showing 2 changed files
... ...
@@ -446,6 +446,10 @@ these defaults are not set, `ulimit` settings will be inherited, if not set on
446 446
 `docker run`, from the Docker daemon. Any `--ulimit` options passed to 
447 447
 `docker run` will overwrite these defaults.
448 448
 
449
+Be careful setting `nproc` with the `ulimit` flag as `nproc` is designed by Linux to
450
+set the maximum number of processes available to a user, not to a container. For details
451
+please check the [run](run.md) reference.
452
+
449 453
 ## Miscellaneous options
450 454
 
451 455
 IP masquerading uses address translation to allow containers without a public
... ...
@@ -479,3 +479,19 @@ available in the default container, you can set these using the `--ulimit` flag.
479 479
 
480 480
 The values are sent to the appropriate `syscall` as they are set.
481 481
 Docker doesn't perform any byte conversion. Take this into account when setting the values.
482
+
483
+#### For `nproc` usage:
484
+
485
+Be careful setting `nproc` with the `ulimit` flag as `nproc` is designed by Linux to set the
486
+maximum number of processes available to a user, not to a container.  For example, start four
487
+containers with `daemon` user:
488
+
489
+
490
+    docker run -d -u daemon --ulimit nproc=3 busybox top
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
+
495
+The 4th container fails and reports "[8] System error: resource temporarily unavailable" error. 
496
+This fails because the caller set `nproc=3` resulting in the first three containers using up 
497
+the three processes quota set for the `daemon` user.