Add --revive-stopped flag to start stopped containers after an update (#403)

* Add --revive-stopped flag to start stopped containers after an update

* Update arguments.md
pull/408/head
Zois Pagoulatos 5 years ago committed by Simon Aronsson
parent 63e5049160
commit 2d8507ca31

@ -93,11 +93,13 @@ func PreRun(cmd *cobra.Command, args []string) {
noPull, _ := f.GetBool("no-pull")
includeStopped, _ := f.GetBool("include-stopped")
reviveStopped, _ := f.GetBool("revive-stopped")
removeVolumes, _ := f.GetBool("remove-volumes")
client = container.NewClient(
!noPull,
includeStopped,
reviveStopped,
removeVolumes,
)

@ -97,6 +97,16 @@ Environment Variable: WATCHTOWER_INCLUDE_STOPPED
Default: false
```
## Revive stopped
Start any stopped containers that have had their image updated. This argument is only usable with the `--include-stopped` argument.
```
Argument: --revive-stopped
Environment Variable: WATCHTOWER_REVIVE_STOPPED
Type: Boolean
Default: false
```
## Poll interval
Poll interval (in seconds). This value controls how frequently watchtower will poll for new images.

@ -94,6 +94,12 @@ func RegisterSystemFlags(rootCmd *cobra.Command) {
viper.GetBool("WATCHTOWER_INCLUDE_STOPPED"),
"Will also include created and exited containers")
flags.BoolP(
"revive-stopped",
"",
viper.GetBool("WATCHTOWER_REVIVE_STOPPED"),
"Will also start stopped containers that were updated, if include-stopped is active")
flags.BoolP(
"enable-lifecycle-hooks",
"",
@ -128,7 +134,7 @@ func RegisterNotificationFlags(rootCmd *cobra.Command) {
"",
viper.GetString("WATCHTOWER_NOTIFICATION_EMAIL_TO"),
"Address to send notification emails to")
flags.IntP(
"notification-email-delay",
"",

@ -38,7 +38,7 @@ type Client interface {
// * DOCKER_HOST the docker-engine host to send api requests to
// * DOCKER_TLS_VERIFY whether to verify tls certificates
// * DOCKER_API_VERSION the minimum docker api version to work with
func NewClient(pullImages bool, includeStopped bool, removeVolumes bool) Client {
func NewClient(pullImages bool, includeStopped bool, reviveStopped bool, removeVolumes bool) Client {
cli, err := dockerclient.NewClientWithOpts(dockerclient.FromEnv)
if err != nil {
@ -50,6 +50,7 @@ func NewClient(pullImages bool, includeStopped bool, removeVolumes bool) Client
pullImages: pullImages,
removeVolumes: removeVolumes,
includeStopped: includeStopped,
reviveStopped: reviveStopped,
}
}
@ -58,6 +59,7 @@ type dockerClient struct {
pullImages bool
removeVolumes bool
includeStopped bool
reviveStopped bool
}
func (client dockerClient) ListContainers(fn t.Filter) ([]Container, error) {
@ -203,7 +205,7 @@ func (client dockerClient) StartContainer(c Container) (string, error) {
}
if !c.IsRunning() {
if !c.IsRunning() && !client.reviveStopped {
return createdContainer.ID, nil
}

Loading…
Cancel
Save