diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index aa49b2d513b..932bebdef35 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -258,6 +258,9 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool) } } + // Set container as invalid so it can no longer be used + c.valid = false + // Clean up network namespace, cgroups, mounts if err := c.cleanup(); err != nil { if cleanupErr == nil { @@ -289,9 +292,6 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool) } } - // Set container as invalid so it can no longer be used - c.valid = false - return cleanupErr }