I have docker-compose file that creates two internal interface for a pihole docker container. One network interface is being utilised for communication between the different containers (including a reserve proxy for the pihole interface) and the other interface is within the IP range of my internal network (192.168.2.0) serving the DHCP and DNS service that the pihole service provides.
DHCP requests should be always served to this specific interface which is hardwired in the DHCP (DNSMASQ) configuration file. From time to time I have to recreate the container (i.e., image updates) and it seems to be completely random if the DHCP serving interface is being generated as eth0 or eth1.
Is it possible to preset the interface in the docker-compose file or anywhere else to it's always either eth0 or eth1?
networks:
pihole_network:
driver: macvlan
driver_opts:
parent: eth2
ipam:
config:
- subnet: 192.168.2.0/24
gateway: 192.168.2.1
ip_range: 192.168.2.50/32
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
ports:
- "53:53/tcp"
- "192.168.2.199:53:53/udp"
- "67:67/udp"
- "8081:8080/tcp"
- "30001:443/tcp"
networks:
pihole_network:
ipv4_address: 192.168.2.50
dns:
- 127.0.0.1
- 8.8.8.8
environment:
ServerIP: 192.168.2.50
TZ: 'Europe/Zurich'
WEBPASSWORD: 'XXX'
DHCP_ACTIVE: 'false'
WEBTHEME: 'default-dark'
WEB_PORT: 8081
DNSMASQ_USER: 'root'
labels:
// LABELS //
volumes:
// VOLUMES //
cap_add:
- NET_ADMIN
restart: unless-stopped
logging:
driver: json-file
options:
max-size: "10m"
Just as fyi, the second network (the bridge network for cross container communication) is just being connected through one time docker container which connects the container to the bridge
connect-bridge:
image: stmllr/docker-client
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
depends_on:
- pihole
command: /bin/sh -c 'docker ps -f label=networks=bridge --format "{{.ID}}" | xargs docker network connect bridge pihole'