diff --git a/podman_compose.py b/podman_compose.py index f18d111..4e15d1e 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -2587,6 +2587,10 @@ def compose_run_update_container_from_args(compose, cnt, args): del cnt[k] except KeyError: pass + if args.publish: + ports = cnt.get("ports", []) + ports.extend(norm_ports(args.publish)) + cnt["ports"] = ports if args.volume: # TODO: handle volumes volumes = clone(cnt.get("volumes", None) or []) diff --git a/pytests/test_compose_run_update_container_from_args.py b/pytests/test_compose_run_update_container_from_args.py index 2ce9b2f..3bf2a13 100644 --- a/pytests/test_compose_run_update_container_from_args.py +++ b/pytests/test_compose_run_update_container_from_args.py @@ -35,6 +35,21 @@ class TestComposeRunUpdateContainerFromArgs(unittest.TestCase): } self.assertEqual(cnt, expected_cnt) + def test_publish_ports(self): + cnt = get_minimal_container() + compose = get_minimal_compose() + args = get_minimal_args() + args.publish = ["1111", "2222:2222"] + + compose_run_update_container_from_args(compose, cnt, args) + + expected_cnt = { + "name": "default_name", + "ports": ["1111", "2222:2222"], + "tty": True, + } + self.assertEqual(cnt, expected_cnt) + def get_minimal_container(): return {} @@ -53,6 +68,7 @@ def get_minimal_args(): name="default_name", rm=None, service=None, + publish=None, service_ports=None, user=None, volume=None,