mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 14:10:12 +01:00
Support for --cleanup flag
The --cleanup flag will cause watchtower to automatically remove the old image after a container is restart with a new image.
This commit is contained in:
parent
b8ba80df2d
commit
dd80aa4a0d
10 changed files with 117 additions and 7 deletions
|
|
@ -15,7 +15,7 @@ var (
|
|||
|
||||
func allContainersFilter(container.Container) bool { return true }
|
||||
|
||||
func Update(client container.Client) error {
|
||||
func Update(client container.Client, cleanup bool) error {
|
||||
log.Info("Checking containers for updated images")
|
||||
|
||||
containers, err := client.ListContainers(allContainersFilter)
|
||||
|
|
@ -70,6 +70,10 @@ func Update(client container.Client) error {
|
|||
if err := client.StartContainer(container); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
if cleanup {
|
||||
client.RemoveImage(container)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue