Given: We have a service that is currently run on a VM with a MAC address of 4E-3C-FC-EF-C5-45. Our DHCP server assigns it a name of "pixie1". The IP address doesn't matter because everything accesses it by name.
The Goal: We're trying to move most of our services from VMs to containers, so we've set up a new machine to host the docker images. All of these services need to continue operating such that they can be accessed by host name on the existing lan (10.41.x.x) - which is managed using static leases from our DHCP server.
The Problem: There's a TON of conflicting information out there over the past 8 years that say "it can't be done", "it can be done", "use macvlan", "use ipvlan", and so on.
Every couple of years, I've looked into this and spent days diving into rabbit holes that lead nowhere.
Most of the "solutions" involve self-assigning a particular IP address, but then we end up with the exact problem that DHCP solves: No central management of IP addresses and hostnames. Or we end up with split management where multiple DHCP servers (the central corporate one, and now also a local Docker one), which now have to coordiante with each other.
There's also docker-net-dhcp, which hasn't been maintained in years.
It doesn't have to be docker. I'll use podman or anything that can run Dockerfiles - I just want to be able to make a Dockerfile or compose.yml and get a hostname and IP address from our central DHCP server's static leases (by mac address).
What I'd like to know is:
Can this actually be done in docker-compose (or podman-compose or whatever), using ONLY the corporate DHCP server to provide host names and IP addresses?
HOW specifically does one do it (assuming the docker hosting machine is connected to 10.41.x.x via /dev/eno0 and the physical host has, for example, address 10.41.0.55)? As in make the docker image say "Hi, I'm a machine on this physical LAN (10.41.x.x), and I have MAC address 4E-3C-FC-EF-C5-45. Corporate DHCP server, please give me an IP address and host name!"
-p <ip_address>:<host_port>:<container_port>, where<ip_address>is something that you would assign statically to the host, not the container.ip netnson the host. I didn't bother to test that far.)