Building dnsmasq
docker-compose file with DHCP enabled
Creating Dockerfile
Create Dockerfile as below, the VOLUME /data
is pointing to configuration folder
FROM ubuntu:latest
VOLUME /data
RUN apt update
RUN apt install dnsmasq -y
RUN apt install iproute2 -y
CMD dnsmasq -q -d --conf-file=/data/dnsmasq.conf --dhcp-broadcast
Creating docker-compose.yml
file
Must add cap_add
parameter.
version: '2'
services:
dnsmasq:
container_name: dnsmasq
image: dnsmasq
build:
context: .
dockerfile: Dockerfile.dnsmasq
restart: unless-stopped
volumes:
- /app/dnsmasq/data:/data
networks:
- my_macvlan_250
cap_add:
- NET_ADMIN
networks:
my_macvlan_250:
external: true
This is the same as below command
docker run --cap-add=NET_ADMIN --name dnsmasq -d -it --restart unless-stopped -v /app/dnsmasq/data:/data --network my_macvlan_250 dnsmasq