Hey folks, looking into migrating one of my larger servers to NixOS and am stuck on something. In a few cases, I run multiple instances of a single app if I’m using it in distinct contexts (E.g. I have a Gitea instance for personal projects and another for a shared context where I have a few commercial and open source projects and other team members.) Some services support multiple instances while others don’t, and I’d rather not use an entirely separate server just for another Gitea when the first will do quite nicely. I’ve come up with a couple different approaches but I don’t like either all that much, and am wondering if there’s another option I haven’t considered or if I’m missing something in one of these?
Simplest would be using NixOS containers. I don’t necessarily want to manage coordinating a fleet of private IPs across each container, keeping them in sync, tracking which IP maps to which instance, etc. I’d also rather not do similar with ports if I can avoid it. Can I either:
- Use systemd network namespaces/isolation to give each container its own namespace on the host so each can bind its own port? I’m guessing this is what the private networking feature already does–I just didn’t know if isolation was capable of, say, letting each Gitea container have its own port 3000 somehow.
- Use networking shenanigans to give containers addresses via DHCP, then map back to their hostnames somehow?
The other option, of course, is to just use Podman/Docker and declarative container configs. I may ultimately go that route, but would rather stick closer to NixOS if possible.
Thanks a bunch.