Score:0

Distribute IPs from DHCP server in host network to docker containers

cn flag

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:

  1. 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?
  2. 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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.