This Docker image is suitable for running a DHCP server for your docker host network. It is based on ISC DHCP server which is bundled with the latest Debian distribution.
- Install Docker with the instructions on https://www.docker.com.
- Check head of Dockerfile :-)
Provide DHCP service to the host network of the machine running Docker. For that you need
to create a configuration for the DHCP server, start the container with the
--net host
docker run option (or using compose) and specify the network interfaces you
want to provide DHCP service on, as commands in the case of compose.
- Create
data
folder for config and leases. - Create
data/dhcpd.conf
with subnet clauses for the specified network interfaces. - Run
docker run -it --rm --init --net host -v "$(pwd)/data":/data networkboot/dhcpd [<interfaces>]
.dhcpd
will automatically start and display its logs on the console. - Create a docker compose or copy content and modify for customized running DHCP server
To use a DHCPv6-Server you have to pass DHCPD_PROTOCOL=6
as enviroment variable
The entrypoint script in the docker image takes care of running the DHCP
server as the same user that owns the data
folder. This ensures that the
permissions on the files inside the data
folder is kept consistent.
If a /data
volume is not provided with a dhcpd.conf
inside it, the
container will exit early with an error message.
It is licensed under the Apache 2.0 license.
See the file LICENSE for full legal details.