Also, you are using docker-compose, much better off using the standard docker images for each service and running many services.
I would do something like this:
version: '3.8'
services:
pihole:
image: pihole/pihole:latest
container_name: pihole
environment:
TZ: 'America/New_York' # Set your timezone
WEBPASSWORD: 'securepassword' # Set a secure password for Pi-hole
ports:
- "53:53/tcp"
- "53:53/udp"
- "80:80" # Web admin interface
volumes:
- pihole_data:/etc/pihole
- dnsmasq_data:/etc/dnsmasq.d
restart: unless-stopped
depends_on:
- unbound
networks:
pihole_net:
ipv4_address: 192.168.1.2
unbound:
image: mvance/unbound:latest
container_name: unbound
ports:
- "5335:53/udp" # Local Unbound DNS resolution
volumes:
- unbound_data:/opt/unbound/etc/unbound
restart: unless-stopped
networks:
pihole_net:
ipv4_address: 192.168.1.3
keepalived:
image: osixia/keepalived:latest
container_name: keepalived
environment:
KEEPALIVED_UNICAST_PEERS: '#PYTHON2BASH:["192.168.1.2","192.168.1.3"]' # Adjust peer IPs
KEEPALIVED_ROUTER_ID: '42'
KEEPALIVED_PASSWORD: 'securepassword'
volumes:
- keepalived_data:/container/service/keepalived/assets
restart: unless-stopped
networks:
pihole_net:
ipv4_address: 192.168.1.4
volumes:
pihole_data:
dnsmasq_data:
unbound_data:
keepalived_data:
networks:
pihole_net:
driver: bridge
ipam:
config:
- subnet: 192.168.1.0/24
This is not tested. May not work, May not serve your needs. Could harass your cat. Your mileage may vary.
Let me know if you have questions.