Adds an error check on container removal to ignore errors caused by containers that were removed by other means (errors of type ErrNotFound).

This can be useful when the start of the containers is managed by docker compose or an external system such as systemd.
This commit is contained in:
Florian Hübner 2022-11-22 19:42:46 +01:00 committed by nils måsén
parent a4d00bfd75
commit 2dc4ebbcef

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
}
}