浏览代码

Merge pull request #24435 from cpuguy83/24350_cleanup_on_no_running_containers

Fix daemon not cleaned up w/ live restore enabled
Tõnis Tiigi 9 年之前
父节点
当前提交
a34534fe95
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      daemon/daemon.go

+ 5 - 1
daemon/daemon.go

@@ -652,8 +652,12 @@ func (daemon *Daemon) Shutdown() error {
 	// Keep mounts and networking running on daemon shutdown if
 	// Keep mounts and networking running on daemon shutdown if
 	// we are to keep containers running and restore them.
 	// we are to keep containers running and restore them.
 	if daemon.configStore.LiveRestore {
 	if daemon.configStore.LiveRestore {
-		return nil
+		// check if there are any running containers, if none we should do some cleanup
+		if ls, err := daemon.Containers(&types.ContainerListOptions{}); len(ls) != 0 || err != nil {
+			return nil
+		}
 	}
 	}
+
 	if daemon.containers != nil {
 	if daemon.containers != nil {
 		logrus.Debug("starting clean shutdown of all containers...")
 		logrus.Debug("starting clean shutdown of all containers...")
 		daemon.containers.ApplyAll(func(c *container.Container) {
 		daemon.containers.ApplyAll(func(c *container.Container) {