From a4da384b559796ecbf49746e655876138d494864 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Tue, 3 Nov 2020 10:01:21 -0500 Subject: Ensure that --net=host/pod/container/none warn with -p Setting port mappings only works when CNI is configuring our network (or slirp4netns, in the rootless case). This is not the case with `--net=host`, `--net=container:`, and joining the network namespace of the pod we are part of. Instead of allowing users to do these things and then be confused why they do nothing, let's match Docker and return a warning that your port mappings will do nothing. Signed-off-by: Matthew Heon --- test/system/030-run.bats | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/system') diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 6b6964c63..b64e80f05 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -522,4 +522,9 @@ json-file | f run_podman untag $IMAGE $newtag $newtag2 } +@test "podman run with --net=host and --port prints warning" { + run_podman run -d --rm -p 8080 --net=host $IMAGE ls > /dev/null + is "$output" ".*Port mappings have been discarded as one of the Host, Container, Pod, and None network modes are in use" +} + # vim: filetype=sh -- cgit v1.2.3-54-g00ecf