Code Monkey home page Code Monkey logo

gocker's Introduction

Docker 专栏自己动手写 Docker 源码

gocker's People

Contributors

wilhelmguo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gocker's Issues

Cgroups.Apply方法无法生效

Cgroups.Apply方法代码

gocker/cgroups/cgoups.go

Lines 25 to 47 in b01d7f2

func (c *Cgroups) Apply(pid int) error {
if c.CPU != 0 {
cpuCgroupPath, err := getCgroupPath("cpu", true)
if err != nil {
return err
}
err = ioutil.WriteFile(path.Join(cpuCgroupPath, "tasks"), []byte(strconv.Itoa(pid)), 0644)
if err != nil {
return fmt.Errorf("set cgroup cpu fail %v", err)
}
}
if c.Memory != 0 {
memoryCgroupPath, err := getCgroupPath("memory", true)
if err != nil {
return err
}
err = ioutil.WriteFile(path.Join(memoryCgroupPath, "tasks"), []byte(strconv.Itoa(pid)), 0644)
if err != nil {
return fmt.Errorf("set cgroup memory fail %v", err)
}
}
return nil
}

Apply之前未将命令行参数中的cpu和memory设置为对象cgroup的成员变量

gocker/runc/run.go

Lines 76 to 87 in b01d7f2

// use gocker as cgroup name
cgroup := cgroups.NewCgroups()
defer cgroup.Destroy()
cpus := context.Int("cpus")
if cpus != 0 {
cgroup.SetCPULimit(cpus)
}
m := context.Int("m")
if m != 0 {
cgroup.SetMemoryLimit(m)
}
cgroup.Apply(cmd.Process.Pid)

已提PR尝试解决: #1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.