From 17b60891b6a4ce4e5c0e8ddae1a2dd9490a0e0d8 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 13 Mar 2019 12:52:12 +0100 Subject: rm: fix cleanup race we fire the cleanup process asynchronously so we might race with a command like: podman run --rm --name foo ... && podman run --rm --name foo Fix it by ensuring the container is deleted before we exit. This will race with the "cleanup" process, but it is fine as one of the two commands will fail with ErrNoSuchCtr while the other succeeds. Closes: https://github.com/containers/libpod/issues/2619 Signed-off-by: Giuseppe Scrivano --- cmd/podman/run.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 130c5a32c..a92d5d3db 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -166,6 +166,10 @@ func runCmd(c *cliconfig.RunValues) error { exitCode = int(ecode) } + if c.IsSet("rm") { + runtime.RemoveContainer(ctx, ctr, false, true) + } + return nil } -- cgit v1.2.3-54-g00ecf