forked from extern/podman-compose
#512: only use --net when bridge
This commit is contained in:
parent
92662f3409
commit
265e0ca32a
@ -742,6 +742,7 @@ def get_net_args(compose, cnt):
|
|||||||
mac_address = cnt.get("mac_address", None)
|
mac_address = cnt.get("mac_address", None)
|
||||||
if mac_address:
|
if mac_address:
|
||||||
net_args.extend(["--mac-address", mac_address])
|
net_args.extend(["--mac-address", mac_address])
|
||||||
|
is_bridge = False
|
||||||
net = cnt.get("network_mode", None)
|
net = cnt.get("network_mode", None)
|
||||||
if net:
|
if net:
|
||||||
if net == "host":
|
if net == "host":
|
||||||
@ -755,9 +756,13 @@ def get_net_args(compose, cnt):
|
|||||||
elif net.startswith("container:"):
|
elif net.startswith("container:"):
|
||||||
other_cnt = net.split(":", 1)[1].strip()
|
other_cnt = net.split(":", 1)[1].strip()
|
||||||
net_args.extend(["--network", f"container:{other_cnt}"])
|
net_args.extend(["--network", f"container:{other_cnt}"])
|
||||||
|
elif net.startswith("bridge"):
|
||||||
|
is_bridge=True
|
||||||
else:
|
else:
|
||||||
print(f"unknown network_mode [{net}]")
|
print(f"unknown network_mode [{net}]")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
is_bridge=True
|
||||||
proj_name = compose.project_name
|
proj_name = compose.project_name
|
||||||
default_net = compose.default_net
|
default_net = compose.default_net
|
||||||
nets = compose.networks
|
nets = compose.networks
|
||||||
@ -788,6 +793,7 @@ def get_net_args(compose, cnt):
|
|||||||
)
|
)
|
||||||
net_names.add(net_name)
|
net_names.add(net_name)
|
||||||
net_names_str = ",".join(net_names)
|
net_names_str = ",".join(net_names)
|
||||||
|
if is_bridge:
|
||||||
net_args.extend(["--net", net_names_str, "--network-alias", ",".join(aliases)])
|
net_args.extend(["--net", net_names_str, "--network-alias", ",".join(aliases)])
|
||||||
if ip:
|
if ip:
|
||||||
net_args.append(f"--ip={ip}")
|
net_args.append(f"--ip={ip}")
|
||||||
|
Loading…
Reference in New Issue
Block a user