From b07ba2441962b81f02444ba54332bab2f16a6f32 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 20 Oct 2022 13:19:55 +0200 Subject: [PATCH] quadlet: Support multiple Network= This is supported by podman run with --network, so makes sense. Signed-off-by: Alexander Larsson --- docs/source/markdown/podman-systemd.unit.5.md | 2 ++ pkg/systemd/quadlet/quadlet.go | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/source/markdown/podman-systemd.unit.5.md b/docs/source/markdown/podman-systemd.unit.5.md index c8b39cf16b..aa0667c31b 100644 --- a/docs/source/markdown/podman-systemd.unit.5.md +++ b/docs/source/markdown/podman-systemd.unit.5.md @@ -240,6 +240,8 @@ Specify a custom network for the container. This has the same format as the `--n to `podman run`. For example, use `host` to use the host network in the container, or `none` to not set up networking in the container. +This key can be listed multiple times. + #### `ExposeHostPort=` Exposes a port, or a range of ports (e.g. `50-59`), from the host to the container. Equivalent diff --git a/pkg/systemd/quadlet/quadlet.go b/pkg/systemd/quadlet/quadlet.go index ffb1d6f9fe..d3bde16fdc 100644 --- a/pkg/systemd/quadlet/quadlet.go +++ b/pkg/systemd/quadlet/quadlet.go @@ -373,9 +373,11 @@ func ConvertContainer(container *parser.UnitFile, isUser bool) (*parser.UnitFile podman.addf("--tz=%s", timezone) } - network, ok := container.Lookup(ContainerGroup, KeyNetwork) - if ok && len(network) > 0 { - podman.addf("--network=%s", network) + networks := container.LookupAll(ContainerGroup, KeyNetwork) + for _, network := range networks { + if len(network) > 0 { + podman.addf("--network=%s", network) + } } // Run with a pid1 init to reap zombies by default (as most apps don't do that)