From 06c939e5279eb62b9088202a27d02d67c1cba6a5 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Wed, 18 Mar 2015 16:32:06 -0700 Subject: [PATCH 1/2] Ensure the container state is removed on daemon boot This ensures that the libcontainer state is fully removed for a container after it is terminated. Signed-off-by: Michael Crosby --- daemon/execdriver/native/driver.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon/execdriver/native/driver.go b/daemon/execdriver/native/driver.go index e582af17fc..98ad5fd6d1 100644 --- a/daemon/execdriver/native/driver.go +++ b/daemon/execdriver/native/driver.go @@ -242,6 +242,7 @@ func (d *driver) Unpause(c *execdriver.Command) error { } func (d *driver) Terminate(c *execdriver.Command) error { + defer d.cleanContainer(c.ID) // lets check the start time for the process active := d.activeContainers[c.ID] if active == nil { @@ -262,7 +263,6 @@ func (d *driver) Terminate(c *execdriver.Command) error { err = syscall.Kill(pid, 9) syscall.Wait4(pid, nil, 0, nil) } - d.cleanContainer(c.ID) return err @@ -302,7 +302,7 @@ func (d *driver) cleanContainer(id string) error { d.Lock() delete(d.activeContainers, id) d.Unlock() - return os.RemoveAll(filepath.Join(d.root, id, "container.json")) + return os.RemoveAll(filepath.Join(d.root, id)) } func (d *driver) createContainerRoot(id string) error { From 2b12b099b8c60f02142ab8ece68987a8fba00292 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Thu, 19 Mar 2015 14:27:17 -0700 Subject: [PATCH 2/2] Mount libcontainer state dir in tmpfs Signed-off-by: Michael Crosby --- daemon/execdriver/native/driver.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/daemon/execdriver/native/driver.go b/daemon/execdriver/native/driver.go index 98ad5fd6d1..99019d0f8e 100644 --- a/daemon/execdriver/native/driver.go +++ b/daemon/execdriver/native/driver.go @@ -60,7 +60,12 @@ func NewDriver(root, initPath string) (*driver, error) { cgm = libcontainer.SystemdCgroups } - f, err := libcontainer.New(root, cgm, libcontainer.InitPath(reexec.Self(), DriverName)) + f, err := libcontainer.New( + root, + cgm, + libcontainer.InitPath(reexec.Self(), DriverName), + libcontainer.TmpfsRoot, + ) if err != nil { return nil, err }