This Docker image is suitable for running a DHCP server for your docker host network. It uses ISC DHCP server which is bundled with the alpine distribution.
The most common use-case is to 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 and specify the network interface you want to provide DHCP service
on.
- Create
data
folder. - Create
data/dhcpd.conf
with a subnet clause for the specified network interface. If you need assistance, you can rundocker run -it --rm microscotch/dhcpd-alpine man dhcpd.conf
for a description of the configuration file syntax. - Run
docker run -it --rm --init --net host -v "$(pwd)/data":/data microscotch/dhcpd-alpine eth0
.dhcpd
will automatically start and display its logs on the console. You can press Ctrl-C to terminate the server.
A simple run
script is also included which makes it quick to iterate on a
configuration until you're satisfied.
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
the data
folder is owned by root, dhcpd is run as the normal dhcpd user.
If you forget to run the docker container with the --net host
option a
warning will be emitted informing you that you've probably forgotten it.
If a /data
volume is not provided with a dhcpd.conf
inside it, the
container will exit early with an error message.
- Install Docker with the instructions on https://www.docker.com.
- Run
./build
to create the local docker imagemicroscotch/dhcpd-alpine
. - In order to build arm or i386 image you have to register qemu
This image uses the following software components:
- Alpine distribution from https://www.alpinelinux.org/.
- ISC DHCP server from https://www.isc.org/downloads/dhcp/.
- Dumb-init from https://github.com/Yelp/dumb-init.
This image is based on work of Robin Smidsrød [email protected].
This project is copyright 2019 Microscotch [email protected] and Copyright 2017 Robin Smidsrød [email protected]
It is licensed under the Apache 2.0 license.
See the file LICENSE for full legal details.