Ver Fonte

Restart conatiner with on-failure policy if exit code != 0

Signed-off-by: Michael Crosby <michael@docker.com>
Michael Crosby há 11 anos atrás
pai
commit
feda8fbb21
1 ficheiros alterados com 2 adições e 1 exclusões
  1. 2 1
      daemon/daemon.go

+ 2 - 1
daemon/daemon.go

@@ -370,7 +370,8 @@ func (daemon *Daemon) restore() error {
 		log.Debugf("Restarting containers...")
 
 		for _, container := range registeredContainers {
-			if container.hostConfig.RestartPolicy.Name == "always" {
+			if container.hostConfig.RestartPolicy.Name == "always" ||
+				(container.hostConfig.RestartPolicy.Name == "on-failure" && container.State.ExitCode != 0) {
 				utils.Debugf("Starting container %s", container.ID)
 
 				if err := container.Start(); err != nil {