I am using the new quadlet to automatically start podman container, getting its ip from the dhcp server using the following systemd config:
adguard.container
[Unit]
Description=Adguard Container
[Container]
Image=docker.io/adguard/adguardhome:latest
AutoUpdate=registry
ContainerName=AdguardHome
HostName=adguard
Volume=/opt/adguardhome/conf:/opt/adguardhome/conf
Volume=/opt/adguardhome/work:/opt/adguardhome/work
Network=adguard.network
[Service]
Restart=always
[Install]
WantedBy=default.target
and
adguard.network
[Unit]
Description=Adguard network
[Network]
NetworkName=adguard-network
Driver=macvlan
Options=parent=enu1u1
Subnet=172.16.0.0/24
IPRange=172.16.0.1/25
Gateway=172.16.0.1
It is working fine.
The problem is that the mac address is not fixed after each startup and I cannot assign the same ip to the container using my dhcp server.
How to fix this macvlan container mac address?
In podman-compose (docker-compose), it is possible to do it with https://docs.docker.com/compose/compose-file/05-services/#mac_address.
Thanks
You can use PodmanArgs=--mac-address 12:34:56:78:9a:bc
to set extra options that aren't valid podman unit keys (as per the manpage).
PodmanArgs
can be specified multiple times and you probably also want --replace
to avoid conflicts.
You can also specify (network) driver options if you need something like Options=isolate=true
.
You can also dry run the quadlet generator to check for errors (like putting values in wrong unit file type):
/usr/libexec/podman/quadlet -dryrun
(+ -user
for rootless)
It will display the complete ExecStart
line for your podman command.