Add --network=none if network_mode: none is set; fixes #1001.

Signed-off-by: bg <bg@nerilex.org>
This commit is contained in:
bg 2024-07-15 15:13:37 +02:00 committed by Povilas Kanapickas
parent 0866492a7e
commit e2eb883709
2 changed files with 2 additions and 1 deletions

View File

@ -876,6 +876,7 @@ def get_net_args(compose, cnt):
if net: if net:
if net == "none": if net == "none":
is_bridge = False is_bridge = False
net_args.append("--network=none")
elif net == "host": elif net == "host":
net_args.append(f"--network={net}") net_args.append(f"--network={net}")
elif net.startswith("slirp4netns"): # Note: podman-specific network mode elif net.startswith("slirp4netns"): # Note: podman-specific network mode

View File

@ -257,7 +257,7 @@ class TestGetNetArgs(unittest.TestCase):
@parameterized.expand([ @parameterized.expand([
("bridge", ["--network=bridge", f"--network-alias={SERVICE_NAME}"]), ("bridge", ["--network=bridge", f"--network-alias={SERVICE_NAME}"]),
("host", ["--network=host"]), ("host", ["--network=host"]),
("none", []), ("none", ["--network=none"]),
("slirp4netns", ["--network=slirp4netns"]), ("slirp4netns", ["--network=slirp4netns"]),
("slirp4netns:cidr=10.42.0.0/24", ["--network=slirp4netns:cidr=10.42.0.0/24"]), ("slirp4netns:cidr=10.42.0.0/24", ["--network=slirp4netns:cidr=10.42.0.0/24"]),
("private", ["--network=private"]), ("private", ["--network=private"]),