I have a Nixos container setup that just servers a web directory on port 80. The container is setup to use the bridge br0 on the host. When I reboot the host, the container starts, but it doesn’t get an ipv4 address. If I stop and start the container, it gets the ipv4 address. I am thinking its something to do with the timing of network interfaces being setup and containers being started but that is a guess and I am unsure how to proceed.
Host network configuration:
networking.networkmanager.enable = true;
networking.useDHCP = false;
networking.bridges = {
"br0" = {
interfaces = [ "enp3s0f2" ];
};
};
networking.interfaces.br0.ipv4.addresses = [ {
address = "192.168.1.10";
prefixLength = 24;
} ];
networking.defaultGateway = "192.168.1.1";
networking.nameservers = ["8.8.8.8" "8.8.4.4"];
networking.firewall.trustedInterfaces = [ "br0" ];
Container config
containers.media-share = {
autoStart = true;
privateNetwork = true;
hostBridge = "br0";
bindMounts = {
"/var/www/media-share.lan/media" = {
hostPath = "/mnt/6tb/media";
isReadOnly = true;
};
};
config = { config, pkgs, ... }: {
system.stateVersion = "23.05";
networking.networkmanager.enable = true;
networking.hostName = "media-share";
networking.firewall.enable = false;
services.httpd.enable = true;
services.httpd.virtualHosts."media-share.lan" = {
documentRoot = "/var/www/media-share.lan";
};
};
};