瀏覽代碼

Merge pull request #16275 from coolljt0725/fix_register_failed_and_start

Fix container register failed during daemon start and then start the container
Antonio Murdaca 9 年之前
父節點
當前提交
db2ac8655d
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      daemon/daemon.go

+ 4 - 2
daemon/daemon.go

@@ -314,7 +314,9 @@ func (daemon *Daemon) restore() error {
 			}
 			}
 
 
 			if err := daemon.Register(container); err != nil {
 			if err := daemon.Register(container); err != nil {
-				logrus.Debugf("Failed to register container %s: %s", container.ID, err)
+				logrus.Errorf("Failed to register container %s: %s", container.ID, err)
+				// The container register failed should not be started.
+				return
 			}
 			}
 
 
 			// check the restart policy on the containers and restart any container with
 			// check the restart policy on the containers and restart any container with
@@ -323,7 +325,7 @@ func (daemon *Daemon) restore() error {
 				logrus.Debugf("Starting container %s", container.ID)
 				logrus.Debugf("Starting container %s", container.ID)
 
 
 				if err := container.Start(); err != nil {
 				if err := container.Start(); err != nil {
-					logrus.Debugf("Failed to start container %s: %s", container.ID, err)
+					logrus.Errorf("Failed to start container %s: %s", container.ID, err)
 				}
 				}
 			}
 			}
 		}(c.container, c.registered)
 		}(c.container, c.registered)