1
0
mirror of https://github.com/containrrr/watchtower.git synced 2024-12-15 09:14:13 +02:00
watchtower/actions/check.go
2015-07-21 16:58:31 +00:00

30 lines
570 B
Go

package actions
import (
"sort"
"github.com/CenturyLinkLabs/watchtower/container"
)
func watchtowerContainersFilter(c container.Container) bool { return c.IsWatchtower() }
func CheckPrereqs() error {
client := container.NewClient()
containers, err := client.ListContainers(watchtowerContainersFilter)
if err != nil {
return err
}
if len(containers) > 1 {
sort.Sort(container.ByCreated(containers))
// Iterate over all containers execept the last one
for _, c := range containers[0 : len(containers)-1] {
client.Stop(c, 60)
}
}
return nil
}