Allow setting ulimits for containers
Signed-off-by: Brian Goff <cpuguy83@gmail.com> Upstream-commit: 3f39050637d454e9ee8075153a917c8bfccb5bae Component: engine
This commit is contained in:
@@ -2,14 +2,16 @@ package execdriver
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/docker/docker/daemon/execdriver/native/template"
|
||||
"github.com/docker/libcontainer"
|
||||
"github.com/docker/libcontainer/devices"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/daemon/execdriver/native/template"
|
||||
"github.com/docker/docker/pkg/ulimit"
|
||||
"github.com/docker/libcontainer"
|
||||
"github.com/docker/libcontainer/devices"
|
||||
)
|
||||
|
||||
// Context is a generic key value pair that allows
|
||||
@@ -99,10 +101,11 @@ type NetworkInterface struct {
|
||||
}
|
||||
|
||||
type Resources struct {
|
||||
Memory int64 `json:"memory"`
|
||||
MemorySwap int64 `json:"memory_swap"`
|
||||
CpuShares int64 `json:"cpu_shares"`
|
||||
Cpuset string `json:"cpuset"`
|
||||
Memory int64 `json:"memory"`
|
||||
MemorySwap int64 `json:"memory_swap"`
|
||||
CpuShares int64 `json:"cpu_shares"`
|
||||
Cpuset string `json:"cpuset"`
|
||||
Rlimits []*ulimit.Rlimit `json:"rlimits"`
|
||||
}
|
||||
|
||||
type ResourceStats struct {
|
||||
|
||||
@@ -58,6 +58,8 @@ func (d *driver) createContainer(c *execdriver.Command) (*libcontainer.Config, e
|
||||
return nil, err
|
||||
}
|
||||
|
||||
d.setupRlimits(container, c)
|
||||
|
||||
cmds := make(map[string]*exec.Cmd)
|
||||
d.Lock()
|
||||
for k, v := range d.activeContainers {
|
||||
@@ -172,6 +174,16 @@ func (d *driver) setCapabilities(container *libcontainer.Config, c *execdriver.C
|
||||
return err
|
||||
}
|
||||
|
||||
func (d *driver) setupRlimits(container *libcontainer.Config, c *execdriver.Command) {
|
||||
if c.Resources == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, rlimit := range c.Resources.Rlimits {
|
||||
container.Rlimits = append(container.Rlimits, libcontainer.Rlimit((*rlimit)))
|
||||
}
|
||||
}
|
||||
|
||||
func (d *driver) setupMounts(container *libcontainer.Config, c *execdriver.Command) error {
|
||||
for _, m := range c.Mounts {
|
||||
container.MountConfig.Mounts = append(container.MountConfig.Mounts, &mount.Mount{
|
||||
|
||||
Reference in New Issue
Block a user