feat: ignore removal error due to non-existing containers (#1481)

Co-authored-by: nils måsén <nils@piksel.se>
Fixes https://github.com/containrrr/watchtower/issues/1480
This commit is contained in:
nothub 2022-12-06 17:40:26 +01:00 committed by GitHub
parent a4d00bfd75
commit 3190ce2df1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 115 additions and 12 deletions

View file

@ -192,6 +192,10 @@ func (client dockerClient) StopContainer(c Container, timeout time.Duration) err
log.Debugf("Removing container %s", shortID)
if err := client.api.ContainerRemove(bg, idStr, types.ContainerRemoveOptions{Force: true, RemoveVolumes: client.RemoveVolumes}); err != nil {
if sdkClient.IsErrNotFound(err) {
log.Debugf("Container %s not found, skipping removal.", shortID)
return nil
}
return err
}
}