mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-21 21:30:48 +02:00
#387 fix: switch to image id map and add additional tests
This commit is contained in:
parent
4e000fa89c
commit
7b8b8e8ad9
9 changed files with 244 additions and 102 deletions
|
@ -73,17 +73,18 @@ func stopStaleContainer(container container.Container, client container.Client,
|
|||
}
|
||||
|
||||
func restartContainersInSortedOrder(containers []container.Container, client container.Client, params UpdateParams) {
|
||||
toDelete := make(map[container.Container]bool)
|
||||
imageIDs := make(map[string]bool)
|
||||
|
||||
for _, container := range containers {
|
||||
if !container.Stale {
|
||||
continue
|
||||
}
|
||||
restartStaleContainer(container, client, params)
|
||||
toDelete[container] = true
|
||||
imageIDs[container.ImageID()] = true
|
||||
}
|
||||
if params.Cleanup {
|
||||
for cont := range toDelete {
|
||||
if err := client.RemoveImage(cont); err != nil {
|
||||
for imageID := range imageIDs {
|
||||
if err := client.RemoveImageByID(imageID); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue