Просмотр исходного кода

Merge pull request #11507 from crosbymichael/container-state

Cleanup libcontainer container state
Jessie Frazelle 10 лет назад
Родитель
Сommit
5a239c0022
1 измененных файлов с 8 добавлено и 3 удалено
  1. 8 3
      daemon/execdriver/native/driver.go

+ 8 - 3
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
 	}
@@ -242,6 +247,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 +268,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 +307,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 {