summaryrefslogtreecommitdiff
path: root/pkg/spec/spec.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2019-07-03 18:18:02 +0200
committerGiuseppe Scrivano <gscrivan@redhat.com>2019-07-08 19:22:54 +0200
commitfb88074e68db25474290535e8a778e39434cc2a2 (patch)
treea2938cf4f442823ba25ddf6755eca68f75458761 /pkg/spec/spec.go
parent1055b22e9b900e5f4d41f39b506de4f2d1aa2f8e (diff)
downloadpodman-fb88074e68db25474290535e8a778e39434cc2a2.tar.gz
podman-fb88074e68db25474290535e8a778e39434cc2a2.tar.bz2
podman-fb88074e68db25474290535e8a778e39434cc2a2.zip
podman: add --ulimit host
add a simple way to copy ulimit values from the host. if --ulimit host is used then the current ulimits in place are copied to the container. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'pkg/spec/spec.go')
-rw-r--r--pkg/spec/spec.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/pkg/spec/spec.go b/pkg/spec/spec.go
index 06d1ac12d..c9548f0d3 100644
--- a/pkg/spec/spec.go
+++ b/pkg/spec/spec.go
@@ -20,6 +20,12 @@ import (
const cpuPeriod = 100000
+type systemUlimit struct {
+ name string
+ max uint64
+ cur uint64
+}
+
func getAvailableGids() (int64, error) {
idMap, err := user.ParseIDMapFile("/proc/self/gid_map")
if err != nil {
@@ -553,6 +559,20 @@ func addRlimits(config *CreateConfig, g *generate.Generator) error {
)
for _, u := range config.Resources.Ulimit {
+ if u == "host" {
+ if len(config.Resources.Ulimit) != 1 {
+ return errors.New("ulimit can use host only once")
+ }
+ hostLimits, err := getHostRlimits()
+ if err != nil {
+ return err
+ }
+ for _, i := range hostLimits {
+ g.AddProcessRlimits(i.name, i.max, i.cur)
+ }
+ break
+ }
+
ul, err := units.ParseUlimit(u)
if err != nil {
return errors.Wrapf(err, "ulimit option %q requires name=SOFT:HARD, failed to be parsed", u)