From 80a47a13d5ee601d0a141e7e82f6b790b45c58d2 Mon Sep 17 00:00:00 2001 From: Muayyad alsadi Date: Sun, 21 Nov 2021 12:35:13 +0200 Subject: [PATCH] add network-alias --- podman_compose.py | 3 ++- tests/nets_test3/docker-compose.yml | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/podman_compose.py b/podman_compose.py index 29e073d..41b144c 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -563,6 +563,7 @@ def assert_cnt_nets(compose, cnt): compose.podman.output([], "network", ["exists", net_name]) def get_net_args(compose, cnt): + service_name = cnt["service_name"] project_name = compose.project_name default_net = compose.default_net nets = compose.networks @@ -573,7 +574,7 @@ def get_net_args(compose, cnt): net_name = net_desc.get("name", None) or f"{project_name}_{net}" net_names.add(net_name) net_names_str = ",".join(net_names) - return ["--net", net_names_str] + return ["--net", net_names_str, "--network-alias", service_name] def container_to_args(compose, cnt, detached=True): # TODO: double check -e , --add-host, -v, --read-only diff --git a/tests/nets_test3/docker-compose.yml b/tests/nets_test3/docker-compose.yml index f8abc71..829435e 100644 --- a/tests/nets_test3/docker-compose.yml +++ b/tests/nets_test3/docker-compose.yml @@ -5,6 +5,7 @@ networks: services: web1: image: busybox + #container_name: web1 hostname: web1 command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"] working_dir: /var/www/html @@ -16,6 +17,7 @@ services: - ./test1.txt:/var/www/html/index.txt:ro web2: image: busybox + #container_name: web2 hostname: web2 command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"] working_dir: /var/www/html