Docker image for kea-dhcp4 with amd64, arm64 and arm32v7.
Using Alpine 3.13
Create dir and files.
mkdir -p kea-dhcp4/conf
cd kea-dhcp4
touch conf/kea-dhcp4.conf
touch dhcp4.leases
touch docker-compose.yml
docker-compose.yml
(same as examples/docker-compose.file.yaml
):
version: "3"
services:
kea-dhcp4:
image: ghcr.io/winglim/kea-dhcp4
# use docker hub
# image: winglim/kea-dhcp4
volumes:
- "$PWD/conf/kea-dhcp4.conf:/etc/kea/kea-dhcp4.conf"
- "$PWD/conf/dhcp4.leases:/var/lib/kea/dhcp4.leases"
restart: always
network_mode: host
container_name: kea-dhcp4
conf/kea-dhcp4.conf
:
For more DHCP4 settings: https://kea.readthedocs.io/en/kea-1.8.1/arm/dhcp4-srv.html
{
"Dhcp4": {
"valid-lifetime": 43200,
"renew-timer": 1000,
"rebind-timer": 2000,
"interfaces-config": {
"interfaces": ["eth0"]
},
"lease-database": {
"type": "memfile",
"persist": true,
"name": "/var/lib/kea/dhcp4.leases"
},
"subnet4": [
{
"subnet": "192.168.1.0/24",
"pools": [
{
"pool": "192.168.1.1 - 192.168.1.255"
}
]
}
]
}
}
NOTICE1: I use kea-admin
to initialize the database, it may take some time, please be patient.
NOTICE2: I use jq
to parse kea-dhcp4.conf
to init database for kea-dhcp, jq CAN NOT parse json with comment, so you need to delete all comments.
docker-compose.yml
(same as examples/docker-compose.db.yaml
):
Use latest-db
tag.
version: "3"
services:
kea-dhcp4:
image: ghcr.io/winglim/kea-dhcp4:latest-db
# use docker hub
# image: winglim/kea-dhcp4:latest-db
volumes:
- "$PWD/conf/kea-dhcp4.conf:/etc/kea/kea-dhcp4.conf"
restart: always
network_mode: host
container_name: kea-dhcp4
depends_on:
- mariadb
mariadb:
image: yobasystems/alpine-mariadb
environment:
- MYSQL_DATABASE=keadhcp4
- MYSQL_ROOT_PASSWORD=keapassword
- MYSQL_USER=keauser
- MYSQL_PASSWORD=keapassword
volumes:
- "$PWD/conf/db:/var/lib/mysql"
ports:
- 3306:3306
restart: always
container_name: kea-mariadb
Edit lease-database
part in conf/kea-dhcp4.conf
:
"lease-database": {
"type": "mysql",
"host": "127.0.0.1",
"port": 3306,
"name": "keadhcp4",
"user": "keauser",
"password": "keapassword"
}