I have a working docker implementation on a fedora workstation that I use to host a Unifi Network Controller application. I use a macvlan to assign a static IP to the controller. The docker network command to create the macvlan is:
docker network create -d macvlan -o parent=enp8s0 --subnet 192.168.110.0/24 --gateway 192.168.110.1 --ip-range 192.168.110.224/27 --aux-address 'host=192.168.110.225' unifinet
The container where the controller runs is assigned a static ip:
docker run --rm --init --network unifinet --ip 192.168.110.226 ....
I would like to implement this using podman as a replacement. Is there a useful online tutorial that explains how to use the implementation of CNI used by podman? Especially the macvlan plugin? I cannot decide if I should use the static IPAM plugin or the local-host IPAM plugin.
Brent Baude's Leasing Routable IP addresses with Podman containers is a good start but is focused on using the dhcp IPAM plugin.
thank you
I see you have a solution that works for you, but I would have suggested using the host-local
IPAM plugin instead, rather than static
(which requires you to explicitly allocate addresses). The corresponding configuration might look something like this:
{
"cniVersion": "0.3.0",
"name": "unifinet",
"plugins": [
{
"type": "macvlan",
"mode": "bridge",
"master": "eth0",
"ipam": {
"type": "host-local",
"ranges": [
[{
"subnet": "192.168.110.0/24",
"rangeStart": "192.168.110.226",
"rangeEnd": "192.168.110.255",
"gateway": "192.168.110.1"
}]
],
"routes": [
{"dst": "0.0.0.0/0"}
]
}
}
]
}
Just like your original docker network create
command, this will allocate addresses on the 192.168.110.0/24 network from the 192.168.110.224/27 range (I've actually specified a range start of 192.168.110.226, which will avoid allocating your 192.168.110.225 address that you've reserved with --aux-address
).
You can start a container with a specific ip using the --ip
argument to podman run
. Given the network defined above, we could run:
podman run --net unifinet --ip 192.168.110.230 ...