mirror of
https://github.com/containers/podman-compose.git
synced 2025-01-13 09:28:16 +01:00
Support and document all podman-specific network_modes
Signed-off-by: Bas Zoetekouw <bas.zoetekouw@surf.nl>
This commit is contained in:
parent
6feff244db
commit
953534a71a
@ -45,3 +45,23 @@ services:
|
||||
ipv4_address: "192.168.1.10"
|
||||
podman.mac_address: "02:bb:bb:bb:bb:bb"
|
||||
```
|
||||
|
||||
## Podman-specific network modes
|
||||
|
||||
Generic docker-compose supports the following values for `network-mode` for a container:
|
||||
|
||||
- `bridge`
|
||||
- `host`
|
||||
- `none`
|
||||
- `service`
|
||||
- `container`
|
||||
|
||||
In addition, podman-compose supports the following podman-specific values for `network-mode`:
|
||||
|
||||
- `slirp4netns[:<options>,...]`
|
||||
- `ns:<options>`
|
||||
- `pasta[:<options>,...]`
|
||||
- `private`
|
||||
|
||||
The options to the network modes are passed to the `--network` option of the `podman create` command
|
||||
as-is.
|
||||
|
@ -789,7 +789,11 @@ def get_net_args(compose, cnt):
|
||||
net_args.append(f"--network={net}")
|
||||
elif net.startswith("slirp4netns"): # Note: podman-specific network mode
|
||||
net_args.append(f"--network={net}")
|
||||
elif net.startswith("ns:"):
|
||||
elif net == "private": # Note: podman-specific network mode
|
||||
net_args.append("--network=private")
|
||||
elif net.startswith("pasta"): # Note: podman-specific network mode
|
||||
net_args.append(f"--network={net}")
|
||||
elif net.startswith("ns:"): # Note: podman-specific network mode
|
||||
net_args.append(f"--network={net}")
|
||||
elif net.startswith("service:"):
|
||||
other_srv = net.split(":", 1)[1].strip()
|
||||
@ -809,6 +813,7 @@ def get_net_args(compose, cnt):
|
||||
default_net = compose.default_net
|
||||
nets = compose.networks
|
||||
cnt_nets = cnt.get("networks", None)
|
||||
|
||||
aliases = [service_name]
|
||||
# NOTE: from podman manpage:
|
||||
# NOTE: A container will only have access to aliases on the first network
|
||||
|
@ -261,7 +261,10 @@ class TestGetNetArgs(unittest.TestCase):
|
||||
("none", []),
|
||||
("slirp4netns", ["--network=slirp4netns"]),
|
||||
("slirp4netns:cidr=10.42.0.0/24", ["--network=slirp4netns:cidr=10.42.0.0/24"]),
|
||||
("private", ["--network=private"]),
|
||||
("pasta", ["--network=pasta"]),
|
||||
("pasta:--ipv4-only,-a,10.0.2.0", ["--network=pasta:--ipv4-only,-a,10.0.2.0"]),
|
||||
("ns:my_namespace", ["--network=ns:my_namespace"]),
|
||||
("container:my_container", ["--network=container:my_container"]),
|
||||
])
|
||||
def test_network_modes(self, network_mode, expected_args):
|
||||
|
Loading…
Reference in New Issue
Block a user