July 29, 20251 yr I have the Docker custom network type setting set to macvlan. On the container settings in the Extra Parameters field I have --mac-address=xx:xx:xx:xx:xx:xxWhen I start the container it works exactly as expected. It connects to my network using the mac address I requested. Great. But if I reboot the server, or stop and then restart docker, or just stop and restart the container it will go back to using a random mac address.To get it to return to using the specified mac address I have to edit the container and make a meaningless change. I usually add or remove a space from the Extra Parameters field. Then when I save the container and it restarts it will use the specified Mac address until the next time the container boots.Is this a bug that will be fixed in an upcoming release or am I doing something wrong? This started happening when I upgraded from 7.1.4 from 7.0. Edited July 29, 20251 yr by ibitio
2 hours ago2 hr Title: Docker container loses its fixed MAC address after restarting the Docker service (Unraid 7.4.0 / Compose)Hi, sorry to post on an old thread but felt relevant to the issue I am having.I've been trying to get a fixed MAC address working for a Docker Compose container on my Unraid 7.4.0 server, but the MAC keeps changing whenever I restart the Docker service or reboot the server.The container is running AdGuard Home with Unbound and Redis, connected to Unraid's eth0 macvlan network. It has a static IP of 192.168.25.9 and I've configured its MAC as 02:42:c0:a8:19:09.Everything works as expected when I initially create or recreate the container using Compose. Docker assigns the correct IP and MAC.However, as soon as I stop and restart the Docker service through Unraid, the container ends up with a different, randomly generated MAC. The static IP remains correct.I can reproduce this consistently without rebooting the server, restarting the docker service from settings seems to cause the issue.My setup:Unraid OS 7.4.0Docker Engine 29.8.2Docker Compose v5.5.0Docker network: eth0 (macvlan, parent vhost0)Container: adguardhome-unbound-redisStatic IP: 192.168.25.9Fixed MAC: 02:42:c0:a8:19:09The relevant part of my Compose configuration is:services: adguardhome-unbound-redis: image: imthai/adguardhome-unbound-redis container_name: adguardhome-unbound-redis networks: eth0: ipv4_address: 192.168.25.9 mac_address: "02:42:c0:a8:19:09" networks: eth0: external: true name: eth0Steps to reproduce:Create the container using Compose with the fixed IP and MAC.Check the MAC using docker inspect. It shows the correct address.Stop and restart the Docker service through Unraid.Check the MAC again. It has changed, even though the IP is still correct.For example, I captured the network configuration immediately before restarting Docker:MAC=02:42:c0:a8:19:09After restarting the Docker service:MAC=52:04:5c:4e:79:20I've tried setting the MAC at both the service and network attachment levels in Compose. I've also disconnected and reconnected the container using the Docker API with an explicit MAC. All of these methods assign the correct MAC initially, but it changes again after restarting Docker.I also ran a separate test using a Docker-managed macvlan network on the same vhost0 parent interface, with a disposable Alpine container and a fixed MAC. That network survived a full Unraid reboot, and when I started the test container again, it retained the correct MAC.This makes me suspect something is happening when Unraid recreates and restores its own eth0 network.I had a look at /etc/rc.d/rc.docker and noticed that Unraid recreates the managed network when Docker starts. In the logs, the AdGuard container is treated as having an additional network that needs restoring, and the restoration process connects it without the configured MAC.I also noticed some skipping invalid stored IP messages during network restoration, although I'm not sure whether they're related.The AdGuard container is managed through Compose and doesn't have an Unraid Docker XML template, which might be relevant.I've seen that Unraid added fixed MAC address handling in recent versions, so I'm wondering whether this is a case that isn't covered by that functionality, particularly for Compose-managed containers using Unraid's built-in macvlan networks.Is this expected behaviour, or could the network restoration process be updated to retain the MAC that was configured before Docker stopped?Happy to provide diagnostics or test a fix if it would help. This is a test server, so I can reproduce the issue without affecting a production setup.Thanks!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.