Merge pull request #15348 from tonistiigi/11008-always-unless-stopped-restart-policy

Add always-unless-stopped restart policy
Upstream-commit: fd8b25c802780683cc5776e6d3aaca9536e7370b
Component: engine
This commit is contained in:
Brian Goff
2015-08-24 13:48:56 -04:00
12 changed files with 99 additions and 10 deletions

View File

@ -79,6 +79,7 @@ type CommonContainer struct {
MountLabel, ProcessLabel string
RestartCount int
HasBeenStartedBefore bool
HasBeenManuallyStopped bool // used for unless-stopped restart policy
hostConfig *runconfig.HostConfig
command *execdriver.Command
monitor *containerMonitor
@ -1066,6 +1067,7 @@ func copyEscapable(dst io.Writer, src io.ReadCloser) (written int64, err error)
func (container *Container) shouldRestart() bool {
return container.hostConfig.RestartPolicy.Name == "always" ||
(container.hostConfig.RestartPolicy.Name == "unless-stopped" && !container.HasBeenManuallyStopped) ||
(container.hostConfig.RestartPolicy.Name == "on-failure" && container.ExitCode != 0)
}