From d3e05de1563436fdcfa656bb499be02e0f40282b Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 8 Sep 2020 12:22:53 +0200 Subject: [PATCH] podman stop: do not cleanup for auto-removal Do not perform a container clean up for containers configured for auto-removal (e.g., via `podman run --rm`). There is a small race window with the other process performing the removal where a clean up during podman-stop may fail since the container has already been removed and cleaned up. As the removing process will clean up the container, we don't have to do it during podman-stop. Fixes: #7384 Signed-off-by: Valentin Rothberg --- pkg/domain/infra/abi/containers.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index 3fee5d394a..0537942e68 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -174,6 +174,12 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin return err } } + if c.AutoRemove() { + // Issue #7384: if the container is configured for + // auto-removal, it might already have been removed at + // this point. + return nil + } return c.Cleanup(ctx) }) if err != nil {