chriscrowe / docker-pihole-unbound

Run Pi-Hole + Unbound on Docker
1.05k stars 274 forks source link

two container - Pihole keeps restarting #147

Open varunpan opened 2 years ago

varunpan commented 2 years ago

Im not sure what is going on but when I run the compose file, it keep restarting pi-hole. I have setup the router to have a static IP using the mac address and i am able to ping it. However, I cannot open pihole and when i check the portainer container logs, it keeps restarting.

I tried this but didnt work: https://github.com/chriscrowe/docker-pihole-unbound/issues/26#issuecomment-782223951

Below is my docker-compose.yml:

version: '3'

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    hostname: pi-hole
    mac_address: d0:ca:ab:cd:ef:01
    cap_add: 
       - NET_ADMIN
    ports:
      - 443/tcp
      - 53/tcp
      - 53/udp
      - 67/udp
      - 80/tcp
      - 22/tcp
    environment:
      - FTLCONF_REPLY_ADDR4=192.168.1.5
      - WEBPASSWORD=Server@12
      - PIHOLE_DNS_=192.168.1.6;192.168.1.12
    volumes:
      - /home/mainpi/.docker/pihole-unbound/pihole/volume:/etc/pihole
      - /home/mainpi/.docker/pihole-unbound/pihole/config/hosts:/etc/hosts
      - /home/mainpi/.docker/pihole-unbound/pihole/config/resolv.conf:/etc/resolv.conf
      - /home/mainpi/.docker/pihole-unbound/pihole/config/dnsmasq.conf:/etc/dnsmasq.d/02-network.conf
      - /home/mainpi/.docker/pihole-unbound/pihole/config/pihole-FTL.conf:/etc/pihole/pihole-FTL.conf
    networks:
      home:
        ipv4_address: 192.168.1.5
    restart: unless-stopped
    privileged: true
  unbound:
    container_name: unbound
    image: mvance/unbound-rpi:latest
    hostname: syn-unbound
    mac_address: d0:ca:ab:cd:ef:02
    ports:
      - 53/tcp
      - 53/udp
    networks:
      home:
        ipv4_address: 192.168.1.6
    restart: unless-stopped
    privileged: true    

networks:
  home:
    driver: macvlan
    driver_opts:
      parent: eth0
    ipam:
      config:
        - subnet: 192.168.1.0/24
          gateway: 192.168.1.1
          ip_range: 192.168.1.5/30

This this log for portainer:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] 01-resolver-resolv: applying... 
[fix-attrs.d] 01-resolver-resolv: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 05-changer-uid-gid.sh: executing... 
[cont-init.d] 05-changer-uid-gid.sh: exited 0.
[cont-init.d] 20-start.sh: executing... 
 ::: Starting docker specific checks & setup for docker pihole/pihole

  [i] Installing configs from /etc/.pihole...
  [i] Existing dnsmasq.conf found... it is not a Pi-hole file, leaving alone!
  [i] Installing /etc/dnsmasq.d/01-pihole.conf...
  [✓] Installed /etc/dnsmasq.d/01-pihole.conf
  [i] Installing /etc/.pihole/advanced/06-rfc6761.conf...
  [✓] Installed /etc/dnsmasq.d/06-rfc6761.conf
sed: cannot rename /etc/pihole/seduBtdZg: Device or resource busy
[cont-init.d] 20-start.sh: exited 4.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] 01-resolver-resolv: applying... 
[fix-attrs.d] 01-resolver-resolv: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 05-changer-uid-gid.sh: executing... 
[cont-init.d] 05-changer-uid-gid.sh: exited 0.
[cont-init.d] 20-start.sh: executing... 
 ::: Starting docker specific checks & setup for docker pihole/pihole

  [i] Installing configs from /etc/.pihole...
  [i] Existing dnsmasq.conf found... it is not a Pi-hole file, leaving alone!
  [i] Installing /etc/dnsmasq.d/01-pihole.conf...
  [✓] Installed /etc/dnsmasq.d/01-pihole.conf
  [i] Installing /etc/.pihole/advanced/06-rfc6761.conf...
  [✓] Installed /etc/dnsmasq.d/06-rfc6761.conf
sed: cannot rename /etc/pihole/sedDKFyTi: Device or resource busy
[cont-init.d] 20-start.sh: exited 4.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.
varunpan commented 2 years ago

i tested without using portainer and i am getting the same issues, where pihole keeps restarting.

varunpan commented 2 years ago

I was able to get it working by updating the docker-compose to:

version: '3.0'

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    hostname: pihole
    mac_address: d0:ca:ab:cd:ef:01
    cap_add:
      - NET_ADMIN
    ports:
      - 443/tcp
      - 53/tcp
      - 53/udp
      - 67/udp
      - 80/tcp
      - 22/tcp
    environment:
      - FTLCONF_REPLY_ADDR4=192.168.1.5
      - WEBPASSWORD=${WEBPASSWORD}
      - PIHOLE_DNS_=192.168.1.6;192.168.1.6
    volumes:
      - /home/mainpi/.docker/pihole-unbound/pihole/config:/etc/dnsmasq.d:rw
      - /home/mainpi/.docker/pihole-unbound/pihole/etc_pihole:/etc/pihole:rw
    networks:
      home:
        ipv4_address: 192.168.1.5
    restart: unless-stopped
    privileged: true
  unbound:
    container_name: unbound
    image: mvance/unbound-rpi:latest
    hostname: syn-unbound
    mac_address: d0:ca:ab:cd:ef:02
    ports:
      - 53/tcp
      - 53/udp
    networks:
      home:
        ipv4_address: 192.168.1.6
    restart: unless-stopped
    privileged: true

networks:
  home:
    driver: macvlan
    driver_opts:
      parent: eth0
    ipam:
      config:
        - subnet: 192.168.1.0/24
          gateway: 192.168.1.1
          ip_range: 192.168.1.5/30

However, it is not blocking ads

yfhyou commented 1 year ago

I also had to choose the Respond only on interface eth0 option in the pihole's DNS settings. By 'working' I'm guessing you mean you can view the pihole page when you go to http://192.168.1.5/admin? Are your devices set to use 192.168.1.5 as their DNS server? Can you run dig pi-hole.net @192.168.1.5 and dig amazonco.uk @192.168.1.5 from your local network? The first should resolve correctly, and the second should be blocked on the default list, returning an answer of 0.0.0.0