Use nsinit for setting up namespace

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-02-19 10:44:29 -08:00
parent c2777d4611
commit 593219d191
4 changed files with 17 additions and 2 deletions

View file

@ -14,6 +14,10 @@ import (
// InitNamespace should be run inside an existing namespace to setup
// common mounts, drop capabilities, and setup network interfaces
func InitNamespace(container *libcontainer.Container) error {
if err := setLogFile(container); err != nil {
return err
}
rootfs, err := resolveRootfs(container)
if err != nil {
return err
@ -138,3 +142,12 @@ func openTerminal(name string, flag int) (*os.File, error) {
}
return os.NewFile(uintptr(r), name), nil
}
func setLogFile(container *libcontainer.Container) error {
f, err := os.OpenFile(container.LogFile, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0655)
if err != nil {
return err
}
log.SetOutput(f)
return nil
}