mirror of https://github.com/docker/docs.git
Happy birthday Docker! cgroup-parent option for docker build. Thanks to Michael, Nathan and Jessie for their support! #42
Signed-off-by: Julien Barbier <write0@gmail.com>
This commit is contained in:
parent
b5ccfca565
commit
bb41193998
|
@ -58,6 +58,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
||||||
flCpuQuota := cmd.Int64([]string{"-cpu-quota"}, 0, "Limit the CPU CFS (Completely Fair Scheduler) quota")
|
flCpuQuota := cmd.Int64([]string{"-cpu-quota"}, 0, "Limit the CPU CFS (Completely Fair Scheduler) quota")
|
||||||
flCPUSetCpus := cmd.String([]string{"-cpuset-cpus"}, "", "CPUs in which to allow execution (0-3, 0,1)")
|
flCPUSetCpus := cmd.String([]string{"-cpuset-cpus"}, "", "CPUs in which to allow execution (0-3, 0,1)")
|
||||||
flCPUSetMems := cmd.String([]string{"-cpuset-mems"}, "", "MEMs in which to allow execution (0-3, 0,1)")
|
flCPUSetMems := cmd.String([]string{"-cpuset-mems"}, "", "MEMs in which to allow execution (0-3, 0,1)")
|
||||||
|
flCgroupParent := cmd.String([]string{"-cgroup-parent"}, "", "Optional parent cgroup for the container")
|
||||||
|
|
||||||
cmd.Require(flag.Exact, 1)
|
cmd.Require(flag.Exact, 1)
|
||||||
cmd.ParseFlags(args, true)
|
cmd.ParseFlags(args, true)
|
||||||
|
@ -276,6 +277,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
||||||
v.Set("cpuquota", strconv.FormatInt(*flCpuQuota, 10))
|
v.Set("cpuquota", strconv.FormatInt(*flCpuQuota, 10))
|
||||||
v.Set("memory", strconv.FormatInt(memory, 10))
|
v.Set("memory", strconv.FormatInt(memory, 10))
|
||||||
v.Set("memswap", strconv.FormatInt(memorySwap, 10))
|
v.Set("memswap", strconv.FormatInt(memorySwap, 10))
|
||||||
|
v.Set("cgroupparent", *flCgroupParent)
|
||||||
|
|
||||||
v.Set("dockerfile", *dockerfileName)
|
v.Set("dockerfile", *dockerfileName)
|
||||||
|
|
||||||
|
|
|
@ -1346,6 +1346,7 @@ func (s *Server) postBuild(eng *engine.Engine, version version.Version, w http.R
|
||||||
buildConfig.CpuQuota = int64Value(r, "cpuquota")
|
buildConfig.CpuQuota = int64Value(r, "cpuquota")
|
||||||
buildConfig.CpuSetCpus = r.FormValue("cpusetcpus")
|
buildConfig.CpuSetCpus = r.FormValue("cpusetcpus")
|
||||||
buildConfig.CpuSetMems = r.FormValue("cpusetmems")
|
buildConfig.CpuSetMems = r.FormValue("cpusetmems")
|
||||||
|
buildConfig.CgroupParent = r.FormValue("cgroupparent")
|
||||||
|
|
||||||
// Job cancellation. Note: not all job types support this.
|
// Job cancellation. Note: not all job types support this.
|
||||||
if closeNotifier, ok := w.(http.CloseNotifier); ok {
|
if closeNotifier, ok := w.(http.CloseNotifier); ok {
|
||||||
|
|
|
@ -121,12 +121,13 @@ type Builder struct {
|
||||||
noBaseImage bool // indicates that this build does not start from any base image, but is being built from an empty file system.
|
noBaseImage bool // indicates that this build does not start from any base image, but is being built from an empty file system.
|
||||||
|
|
||||||
// Set resource restrictions for build containers
|
// Set resource restrictions for build containers
|
||||||
cpuSetCpus string
|
cpuSetCpus string
|
||||||
cpuSetMems string
|
cpuSetMems string
|
||||||
cpuShares int64
|
cpuShares int64
|
||||||
cpuQuota int64
|
cpuQuota int64
|
||||||
memory int64
|
cgroupParent string
|
||||||
memorySwap int64
|
memory int64
|
||||||
|
memorySwap int64
|
||||||
|
|
||||||
cancelled <-chan struct{} // When closed, job was cancelled.
|
cancelled <-chan struct{} // When closed, job was cancelled.
|
||||||
}
|
}
|
||||||
|
|
|
@ -546,12 +546,13 @@ func (b *Builder) create() (*daemon.Container, error) {
|
||||||
b.Config.Image = b.image
|
b.Config.Image = b.image
|
||||||
|
|
||||||
hostConfig := &runconfig.HostConfig{
|
hostConfig := &runconfig.HostConfig{
|
||||||
CpuShares: b.cpuShares,
|
CpuShares: b.cpuShares,
|
||||||
CpuQuota: b.cpuQuota,
|
CpuQuota: b.cpuQuota,
|
||||||
CpusetCpus: b.cpuSetCpus,
|
CpusetCpus: b.cpuSetCpus,
|
||||||
CpusetMems: b.cpuSetMems,
|
CpusetMems: b.cpuSetMems,
|
||||||
Memory: b.memory,
|
CgroupParent: b.cgroupParent,
|
||||||
MemorySwap: b.memorySwap,
|
Memory: b.memory,
|
||||||
|
MemorySwap: b.memorySwap,
|
||||||
}
|
}
|
||||||
|
|
||||||
config := *b.Config
|
config := *b.Config
|
||||||
|
|
|
@ -52,6 +52,7 @@ type Config struct {
|
||||||
CpuQuota int64
|
CpuQuota int64
|
||||||
CpuSetCpus string
|
CpuSetCpus string
|
||||||
CpuSetMems string
|
CpuSetMems string
|
||||||
|
CgroupParent string
|
||||||
AuthConfig *cliconfig.AuthConfig
|
AuthConfig *cliconfig.AuthConfig
|
||||||
ConfigFile *cliconfig.ConfigFile
|
ConfigFile *cliconfig.ConfigFile
|
||||||
|
|
||||||
|
@ -166,6 +167,7 @@ func Build(d *daemon.Daemon, buildConfig *Config) error {
|
||||||
cpuQuota: buildConfig.CpuQuota,
|
cpuQuota: buildConfig.CpuQuota,
|
||||||
cpuSetCpus: buildConfig.CpuSetCpus,
|
cpuSetCpus: buildConfig.CpuSetCpus,
|
||||||
cpuSetMems: buildConfig.CpuSetMems,
|
cpuSetMems: buildConfig.CpuSetMems,
|
||||||
|
cgroupParent: buildConfig.CgroupParent,
|
||||||
memory: buildConfig.Memory,
|
memory: buildConfig.Memory,
|
||||||
memorySwap: buildConfig.MemorySwap,
|
memorySwap: buildConfig.MemorySwap,
|
||||||
cancelled: buildConfig.WaitCancelled(),
|
cancelled: buildConfig.WaitCancelled(),
|
||||||
|
|
Loading…
Reference in New Issue