I have a host service managed by systemd which listens on the Podman default network interface (cni-podman0
) so that containers can talk to it.
The problem I have, is that Podman only creates the network interface when the first container is started. That means when the host service which the containers depend on is started, the network interface isn't up and the service fails to listen on it.
So the dependency chain is: Podman container -needs> Host Service -needs> CNI network interface
But currently the only way I know of to bring up the interface is starting the container.
How can I make systemd tell Podman / CNI to start the default bridge network interface, so that I can depend on that in the host service unit?
Is there a command to bring up the interface explicitly, I could put in a unit file?
See Podman Quadlet, which is an official part of Podman.
Quadlets allow using augmented Podman-related unit files which may depend on each other. It also abstracts away listing arguments in ExecStart=
in favor of unit-specific uses, such as UserNS=keep-id
.
Try creating two separate unit files: a [Container]
with Network=<name>.network
, and a [Network]
in <name>.network
.
Network=
Specify a custom network for the container. This has the same format as the--network
option topodman run
. For example, usehost
to use the host network in the container, ornone
to not set up networking in the container.As a special case, if the
name
of the network ends with.network
, a Podman network calledsystemd-$name
is used, and the generated systemd service contains a dependency on the$name-network.service
. Such a network can be automatically created by using a$name.network
Quadlet file.This key can be listed multiple times.
You can use Quadlet units rootful or rootless, depending on if you place them in, for example, /etc/containers/systemd/
or ~/.config/containers/systemd/
.