Skip to content

Commit 1cd0c31

Browse files
fvoznikashentubot
authored andcommitted
Make default limits the same as with runc
Closes #2 PiperOrigin-RevId: 202997196
1 parent 2941937 commit 1cd0c31

File tree

2 files changed

+45
-30
lines changed

2 files changed

+45
-30
lines changed

README.md

+14-20
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,20 @@ Then restart the Docker daemon.
361361

362362
## FAQ & Known Issues
363363

364+
### Will my container work with gVisor?
365+
366+
gVisor implements a large portion of the Linux surface and while we strive to
367+
make it broadly compatible, there are (and always will be) unimplemented
368+
features and bugs. The only real way to know if it will work is to try. If you
369+
find a container that doesn’t work and there is no known issue, please [file a
370+
bug][bug] indicating the full command you used to run the image. Providing the
371+
debug logs is also helpful.
372+
364373
### What works?
365374

366375
The following applications/images have been tested:
367376

377+
* elasticsearch
368378
* golang
369379
* httpd
370380
* java8
@@ -384,33 +394,17 @@ The following applications/images have been tested:
384394
* tomcat
385395
* wordpress
386396

387-
### What doesn't work yet?
388-
389-
The following applications have been tested and may not yet work:
390-
391-
* elasticsearch: Requires unimplemented socket ioctls. See [bug
392-
#2](https://github.com/google/gvisor/issues/2).
393-
394-
### Will my container work with gVisor?
397+
### My container runs fine with *runc* but fails with *runsc*.
395398

396-
gVisor implements a large portion of the Linux surface and while we strive to
397-
make it broadly compatible, there are (and always will be) unimplemented
398-
features and bugs. The only real way to know if it will work is to try. If you
399-
find a container that doesn’t work and there is no known issue, please [file a
400-
bug][bug] indicating the full command you used to run the image. Providing the
401-
debug logs is also helpful.
399+
If you’re having problems running a container with `runsc` it’s most likely due
400+
to a compatibility issue or a missing feature in gVisor. See **Debugging**,
401+
above.
402402

403403
### When I run my container, docker fails with `flag provided but not defined: -console`
404404

405405
You're using an old version of Docker. Refer to the
406406
[Requirements](#requirements) section for the minimum version supported.
407407

408-
### My container runs fine with *runc* but fails with *runsc*.
409-
410-
If you’re having problems running a container with `runsc` it’s most likely due
411-
to a compatibility issue or a missing feature in gVisor. See **Debugging**,
412-
above.
413-
414408
### I can’t see a file copied with `docker cp` or `kubectl cp`.
415409

416410
For performance reasons, gVisor caches directory contents, and therefore it may

runsc/boot/limits.go

+31-10
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,50 @@ import (
2323

2424
// Mapping from linux resource names to limits.LimitType.
2525
var fromLinuxResource = map[string]limits.LimitType{
26+
"RLIMIT_AS": limits.AS,
27+
"RLIMIT_CORE": limits.Core,
2628
"RLIMIT_CPU": limits.CPU,
27-
"RLIMIT_FSIZE": limits.FileSize,
2829
"RLIMIT_DATA": limits.Data,
29-
"RLIMIT_STACK": limits.Stack,
30-
"RLIMIT_CORE": limits.Core,
31-
"RLIMIT_RSS": limits.Rss,
32-
"RLIMIT_NPROC": limits.ProcessCount,
33-
"RLIMIT_NOFILE": limits.NumberOfFiles,
34-
"RLIMIT_MEMLOCK": limits.MemoryPagesLocked,
35-
"RLIMIT_AS": limits.AS,
30+
"RLIMIT_FSIZE": limits.FileSize,
3631
"RLIMIT_LOCKS": limits.Locks,
37-
"RLIMIT_SIGPENDING": limits.SignalsPending,
32+
"RLIMIT_MEMLOCK": limits.MemoryPagesLocked,
3833
"RLIMIT_MSGQUEUE": limits.MessageQueueBytes,
3934
"RLIMIT_NICE": limits.Nice,
35+
"RLIMIT_NOFILE": limits.NumberOfFiles,
36+
"RLIMIT_NPROC": limits.ProcessCount,
37+
"RLIMIT_RSS": limits.Rss,
4038
"RLIMIT_RTPRIO": limits.RealTimePriority,
4139
"RLIMIT_RTTIME": limits.Rttime,
40+
"RLIMIT_SIGPENDING": limits.SignalsPending,
41+
"RLIMIT_STACK": limits.Stack,
4242
}
4343

4444
func createLimitSet(spec *specs.Spec) (*limits.LimitSet, error) {
45-
ls, err := limits.NewLinuxDistroLimitSet()
45+
ls, err := limits.NewLinuxLimitSet()
4646
if err != nil {
4747
return nil, err
4848
}
49+
50+
// Set default limits based on what containers get by default, ex:
51+
// $ docker run --rm debian prlimit
52+
ls.SetUnchecked(limits.AS, limits.Limit{Cur: limits.Infinity, Max: limits.Infinity})
53+
ls.SetUnchecked(limits.Core, limits.Limit{Cur: limits.Infinity, Max: limits.Infinity})
54+
ls.SetUnchecked(limits.CPU, limits.Limit{Cur: limits.Infinity, Max: limits.Infinity})
55+
ls.SetUnchecked(limits.Data, limits.Limit{Cur: limits.Infinity, Max: limits.Infinity})
56+
ls.SetUnchecked(limits.FileSize, limits.Limit{Cur: limits.Infinity, Max: limits.Infinity})
57+
ls.SetUnchecked(limits.Locks, limits.Limit{Cur: limits.Infinity, Max: limits.Infinity})
58+
ls.SetUnchecked(limits.MemoryPagesLocked, limits.Limit{Cur: 65536, Max: 65536})
59+
ls.SetUnchecked(limits.MessageQueueBytes, limits.Limit{Cur: 819200, Max: 819200})
60+
ls.SetUnchecked(limits.Nice, limits.Limit{Cur: 0, Max: 0})
61+
ls.SetUnchecked(limits.NumberOfFiles, limits.Limit{Cur: 1048576, Max: 1048576})
62+
ls.SetUnchecked(limits.ProcessCount, limits.Limit{Cur: limits.Infinity, Max: limits.Infinity})
63+
ls.SetUnchecked(limits.Rss, limits.Limit{Cur: limits.Infinity, Max: limits.Infinity})
64+
ls.SetUnchecked(limits.RealTimePriority, limits.Limit{Cur: 0, Max: 0})
65+
ls.SetUnchecked(limits.Rttime, limits.Limit{Cur: limits.Infinity, Max: limits.Infinity})
66+
ls.SetUnchecked(limits.SignalsPending, limits.Limit{Cur: 0, Max: 0})
67+
ls.SetUnchecked(limits.Stack, limits.Limit{Cur: 8388608, Max: limits.Infinity})
68+
69+
// Then apply overwrites on top of defaults.
4970
for _, rl := range spec.Process.Rlimits {
5071
lt, ok := fromLinuxResource[rl.Type]
5172
if !ok {

0 commit comments

Comments
 (0)