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:
@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user