forked from extern/podman-compose
add network-alias
This commit is contained in:
parent
872404c3a7
commit
80a47a13d5
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user