mirror of
https://github.com/clearlinux/docker.git
synced 2026-10-03 23:38:24 +00:00
cgroups: Add systemd implementation of cgroups
This implements cgroup.Apply() using the systemd apis. We create a transient unit called "docker-$id.scope" that contains the container processes. We also have a way to set unit specific properties, currently only defining the Slice to put the scope in. Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/dotcloud/docker/pkg/cgroups"
|
||||
"github.com/dotcloud/docker/pkg/libcontainer"
|
||||
"github.com/dotcloud/docker/runtime/execdriver"
|
||||
"github.com/dotcloud/docker/utils"
|
||||
"os"
|
||||
)
|
||||
|
||||
@@ -59,6 +60,19 @@ func createContainer(c *execdriver.Command) *libcontainer.Container {
|
||||
container.Cgroups.MemorySwap = c.Resources.MemorySwap
|
||||
}
|
||||
|
||||
if opts, ok := c.Config["unit"]; ok {
|
||||
props := [][2]string{}
|
||||
for _, opt := range opts {
|
||||
key, value, err := utils.ParseKeyValueOpt(opt)
|
||||
if err == nil {
|
||||
props = append(props, [2]string{key, value})
|
||||
} else {
|
||||
props = append(props, [2]string{opt, ""})
|
||||
}
|
||||
}
|
||||
container.Cgroups.UnitProperties = props
|
||||
}
|
||||
|
||||
// check to see if we are running in ramdisk to disable pivot root
|
||||
container.NoPivotRoot = os.Getenv("DOCKER_RAMDISK") != ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user