Docker controls the IP address assignment for network and endpoint interfaces via libnetwork’s IPAM driver(s). On network creation, you can specify which IPAM driver libnetwork needs to use for the network’s IP address management.
Libnetwork’s default IPAM driver assigns IP addresses based on its own database configuration. For the time being, there is no IPAM driver that would communicate with an external DHCP server, so you need to rely on Docker’s default IPAM driver for container IP address and settings configuration.
The need for external DHCP server support has been identified, however, there is currently no sign that libnetwork developers are working on it. There are community efforts to produce a DHCP IPAM driver, but are currently not production ready.
If you critically rely on your DHCP for IP address management in your production, you can use pipework for the time being.
Alternatively, you can use both DHCP and Docker’s default IPAM on the same Layer 2 segment (a segment that covers both the physical network and the Docker hosted macvlan), with DHCP server providing data for hosts outside Docker host and IPAM providing data for Docker containers. In this case you should split the IP space and ensure DHCP does not suggest IPs in IPAM’s space and vice versa. You can exclude DHCP served IP addresses when creating docker network with
--aux-address parameter, i.e.:
docker network create -d macvlan \ --subnet=10.0.0.0/24 --gateway=10.0.0.1 \ --aux-address=10.0.0.2 \ --aux-address=10.0.0.3 \ --aux-address=10.0.0.4 \ --aux-address=10.0.0.5 \ --aux-address=10.0.0.6 \ -o parent=eth0 \ macvlan0