The command used to launch the DHCP server is
/usr/sbin/dhcpd -f -d -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid
which is what CentOS’ default systemd unit file /usr/lib/systemd/system/dhcpd.service uses, except the -d flag added to reconfigure logging to use stdout/stderr instead of SYSLOG.
The DHCP server needs access to the network interface informations to be able to interpret its configuration - in fact, the DHCP configuration is network interface agnostic and it’s up to the server to match the configurations with the actual network situation. If the DHCP service is meant to serve networks of the Docker host, it has to be given access to the host’s network interfaces with the Docker run flag --net host
The -cf flag tells the DHCP server to expect its configuration file to be located at /etc/dhcp/dhcpd.conf. This file could be added at build time using a
ADD <dhcpd_conf_filepath_on_host> /etc/dhcp/dhcpd.conf
instruction in the Dockerfile, where dhcpd_conf_filepath_on_host is the absolute filepath of the configuration file on the Docker host. However, that would imply that the image has to be rebuild every time the configuration changes. To avoid this, this image rather expects that the configuration file is mounted from the host at runtime using the Docker run flag
The …:ro flag tells Docker to mount it as read-only.
The DHCP server stores its leases in /var/lib/dhcpd. This folder should be made persistant to insure service continuation in case of DHCP server restarts (faulty or not). The easiest way is to use a Docker volume