From 2dc4ebbcefc0f9d9c23cea75fcadd9b87cbcd275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Tue, 22 Nov 2022 19:42:46 +0100 Subject: [PATCH] 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. --- pkg/container/client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/container/client.go b/pkg/container/client.go index f534bd0..7447828 100644 --- a/pkg/container/client.go +++ b/pkg/container/client.go @@ -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 } }