summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-07-24 17:58:36 -0400
committerMatthew Heon <mheon@redhat.com>2022-08-10 16:46:05 -0400
commit7efd81cb8dec7a2a173d3abb904d6be05476980a (patch)
tree53a8f3ac23304444dc78272360d2fb96039591ea /test
parent346b22f0706ef4b01a9442ca47c8ceef827e45e1 (diff)
downloadpodman-7efd81cb8dec7a2a173d3abb904d6be05476980a.tar.gz
podman-7efd81cb8dec7a2a173d3abb904d6be05476980a.tar.bz2
podman-7efd81cb8dec7a2a173d3abb904d6be05476980a.zip
With --rm option remove container if podman run fails
Fixes https://github.com/containers/podman/issues/15049 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> <MH: Fixed cherry-pick conflicts> Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/system/030-run.bats16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/system/030-run.bats b/test/system/030-run.bats
index b3e3cef00..39ff3fcd4 100644
--- a/test/system/030-run.bats
+++ b/test/system/030-run.bats
@@ -853,4 +853,20 @@ EOF
run_podman rm $output
}
+@test "podman run failed --rm " {
+ port=$(random_free_port)
+
+ # Run two containers with the same port bindings. The second must fail
+ run_podman run -p $port:80 --rm -d --name c_ok $IMAGE top
+ run_podman 126 run -p $port:80 -d --name c_fail_no_rm $IMAGE top
+ run_podman 126 run -p $port:80 --rm -d --name c_fail_with_rm $IMAGE top
+ # Prior to #15060, the third container would still show up in ps -a
+ run_podman ps -a --sort names --format '{{.Image}}--{{.Names}}'
+ is "$output" "$IMAGE--c_fail_no_rm
+$IMAGE--c_ok" \
+ "podman ps -a shows running & failed containers, but not failed-with-rm"
+
+ run_podman container rm -f -t 0 c_ok c_fail_no_rm
+}
+
# vim: filetype=sh