I am running several services in docker containers for my homelab, and I need them to be accessible from their own distinct IPs. My host system is running debian "bullseye".
From the docker documentation, it seems natural to use a macvlan
network in bridge mode, and the default way is working correctly for me.
However, I try to use a minimum of manual IPs in my network, and instead try to have my DHCP server assign almost all IPs, even for other servers. Of course, I then configure my DHCP to always assign the same IPs to my servers, based on the MAC-Adresses, but that way I can easily move a server from a testing network to my "live"-network, just by changing the IP assignment in the DHCP server.
I want to be able to do that with docker containers as well, i.e., assign docker containers an IP from DHCP in the hosts network.
Regarding this, I found no information in the docker documentation, and this open question on serverfault.
From my point of view, there are two possible routes to go:
- Create (manually) a subinterface on the host with dynamic IP, then use a
host
network in docker and bind it to the (manually) created subinterface? - Somehow use a
macvlan
network. I do not know, how it needs to be configured to receive DHCP assignment, though.
I would like to either be suggested a better feasible solution, get some help on how to make progress on route 2. or get some affirmation that route 1. is the correct way to go.