mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-16 15:10:12 +01:00
Added noUpdate run parameter, just pull new image without updating container
This commit is contained in:
parent
82a2df38ed
commit
338b54a00e
2 changed files with 40 additions and 31 deletions
|
|
@ -34,7 +34,7 @@ func containerFilter(names []string) container.Filter {
|
|||
// used to start those containers have been updated. If a change is detected in
|
||||
// any of the images, the associated containers are stopped and restarted with
|
||||
// the new image.
|
||||
func Update(client container.Client, names []string, cleanup bool, noRestart bool) error {
|
||||
func Update(client container.Client, names []string, cleanup bool, noRestart bool, noUpdate bool) error {
|
||||
log.Debug("Checking containers for updated images")
|
||||
|
||||
containers, err := client.ListContainers(containerFilter(names))
|
||||
|
|
@ -59,6 +59,7 @@ func Update(client container.Client, names []string, cleanup bool, noRestart boo
|
|||
|
||||
checkDependencies(containers)
|
||||
|
||||
if !noUpdate {
|
||||
// Stop stale containers in reverse order
|
||||
for i := len(containers) - 1; i >= 0; i-- {
|
||||
container := containers[i]
|
||||
|
|
@ -99,6 +100,7 @@ func Update(client container.Client, names []string, cleanup bool, noRestart boo
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
9
main.go
9
main.go
|
|
@ -29,6 +29,7 @@ var (
|
|||
scheduleSpec string
|
||||
cleanup bool
|
||||
noRestart bool
|
||||
noUpdate bool
|
||||
notifier *notifications.Notifier
|
||||
)
|
||||
|
||||
|
|
@ -76,6 +77,11 @@ func main() {
|
|||
Usage: "remove old images after updating",
|
||||
EnvVar: "WATCHTOWER_CLEANUP",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "no-update",
|
||||
Usage: "do not update container",
|
||||
EnvVar: "WATCHTOWER_NO_UPDATE",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "tlsverify",
|
||||
Usage: "use TLS and verify the remote",
|
||||
|
|
@ -146,6 +152,7 @@ func before(c *cli.Context) error {
|
|||
|
||||
cleanup = c.GlobalBool("cleanup")
|
||||
noRestart = c.GlobalBool("no-restart")
|
||||
noUpdate = c.GlobalBool("no-update")
|
||||
|
||||
// configure environment vars for client
|
||||
err := envConfig(c)
|
||||
|
|
@ -177,7 +184,7 @@ func start(c *cli.Context) error {
|
|||
case v := <- tryLockSem:
|
||||
defer func() { tryLockSem <- v }()
|
||||
notifier.StartNotification()
|
||||
if err := actions.Update(client, names, cleanup, noRestart); err != nil {
|
||||
if err := actions.Update(client, names, cleanup, noRestart, noUpdate); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
notifier.SendNotification()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue