Help on setup pi-hole docker on ubuntu 18.04

Port 80 is used on my ubuntu already so I figured I go this guide Free your Synology ports for Docker | Tony Lawrence to setup pi-hole. Here is my complete yaml file (except mask of domainname):

version: '2'

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    hostname: pihole
    domainname: xxx.duckdns.org             # <-- Update
    mac_address: 36:c8:98:79:b5:55
    cap_add:
      - NET_ADMIN
    networks:
      pihole_network:
        ipv4_address: 192.168.2.5   # <-- Update
        #    volumes:
        #- './etc-pihole/:/etc/pihole/'
        #- './etc-dnsmasq.d/:/etc/dnsmasq.d/'
    dns:
      - 127.0.0.1
      - 8.8.8.8
    ports:
      - 443/tcp
      - 53/tcp
      - 53/udp
      - 67/udp
      - 80/tcp
    environment:
      ServerIP: 192.168.2.5         # <-- Update (match ipv4_address)
      VIRTUAL_HOST: pihole.xxx.duckdns.org  # <-- Update (match hostname + domainname)
      WEBPASSWORD: ""                   # <-- Add password (if required)
    restart: unless-stopped

networks:
  pihole_network:
    driver: macvlan
    driver_opts:
            parent: enp9s0  # run this on ubuntu18 to find: sudo lshw -C network
    ipam:
      config:
        - subnet: 192.168.2.0/24            # <-- Update
          gateway: 192.168.2.1              # <-- Update
          ip_range: 192.168.2.4/30        # <-- Update

here is the log file that once started the docker:

[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] 20-start.sh: executing...
 ::: Starting docker specific checks & setup for docker pihole/pihole
WARNING Misconfigured DNS in /etc/resolv.conf: Two DNS servers are recommended, 127.0.0.1 and any backup server
WARNING Misconfigured DNS in /etc/resolv.conf: Primary DNS should be 127.0.0.1 (found 127.0.0.11)

nameserver 127.0.0.11
options ndots:0
  [i] Existing PHP installation detected : PHP version 7.0.33-0+deb9u5

  [i] Installing configs from /etc/.pihole...
  [i] Existing dnsmasq.conf found... it is not a Pi-hole file, leaving alone!
  [✓] Copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf
chown: cannot access '/etc/pihole/dhcp.leases': No such file or directory

  [✓] Password Removed
Using default DNS servers: 8.8.8.8 & 8.8.4.4
DNSMasq binding to default interface: eth0
Added ENV to php:
			"PHP_ERROR_LOG" => "/var/log/lighttpd/error.log",
			"ServerIP" => "192.168.2.5",
			"VIRTUAL_HOST" => "pihole.xxx.duckdns.org",
Using IPv4 and IPv6
::: Preexisting ad list /etc/pihole/adlists.list detected ((exiting setup_blocklists early))
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
https://mirror1.malwaredomains.com/files/justdomains
http://sysctl.org/cameleon/hosts
https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
https://hosts-file.net/ad_servers.txt
::: Testing pihole-FTL DNS: FTL started!
::: Testing lighttpd config: Syntax OK
::: All config checks passed, cleared for startup ...
 ::: Docker start setup complete
  [i] Pi-hole blocking is enabled
  [i] Neutrino emissions detected...
  [✓] Pulling blocklist source list into range

  [i] Target: raw.githubusercontent.com (hosts)
  [✗] Status: Connection Refused
  [✗] List download failed: using previously cached list

  [i] Target: mirror1.malwaredomains.com (justdomains)
  [✗] Status: Connection Refused
  [✗] List download failed: using previously cached list

  [i] Target: sysctl.org (hosts)
  [✗] Status: Connection Refused
  [✗] List download failed: using previously cached list

  [i] Target: s3.amazonaws.com (simple_tracking.txt)
  [✗] Status: Connection Refused
  [✗] List download failed: using previously cached list

  [i] Target: s3.amazonaws.com (simple_ad.txt)
  [✗] Status: Connection Refused
  [✗] List download failed: using previously cached list

  [i] Target: hosts-file.net (ad_servers.txt)
  [✗] Status: Connection Refused
  [✗] List download failed: using previously cached list

  [✓] Consolidating blocklists
  [✓] Extracting domains from blocklists
  [i] Number of domains being pulled in by gravity: 138226
  [✓] Removing duplicate domains
  [i] Number of unique domains trapped in the Event Horizon: 115995
  [i] Nothing to whitelist!
  [i] Number of regex filters: 0
  [✓] Parsing domains into hosts format
  [✓] Cleaning up stray matter

  [✓] DNS service is running
  [i] Pi-hole blocking will be enabled
  [i] Enabling blocking
  [✓] Pi-hole Enabled
[cont-init.d] 20-start.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
Starting lighttpd
Starting crond
Starting pihole-FTL (no-daemon) as root
[services.d] done.

I tried to open 192.168.2.5/admin but it didn't work. Seems something wrong based on log file:

  • WARNING Misconfigured DNS in /etc/resolv.conf: Two DNS servers are recommended, 127.0.0.1 and any backup server
    WARNING Misconfigured DNS in /etc/resolv.conf: Primary DNS should be 127.0.0.1 (found 127.0.0.11)

I do have two DNS set in the yaml file, seems not taking effect?

  • chown: cannot access '/etc/pihole/dhcp.leases': No such file or directory
  • [✗] List download failed: using previously cached list

not sure what wrong this is?

I did follow the ubuntu instruction from the wiki page GitHub - pi-hole/docker-pi-hole: Pi-hole in a docker container. here is file /etc/resolv.conf

nameserver 192.168.2.1

Can anyone help me what setting is wrong and how to fix it?
thanks

You haven't changed port 80, either on the host or in the container. You'll need to map the port you wish to use in place of 80 from host (published) to port 80 in the container (target). Overview | Docker Docs

The author of that guide looks like he responds to questions, best would be to ask him what needs to be configured for your Synology.

I tried below as well, same results

    ports:
      - "443:443/tcp"
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"

The original post there is for Synology but I am using it on ubuntu 18.04 on my laptop.

I wanted borrow the idea of using macvlan driver to solve port conflict. Because in my ubuntu 18.04, I have a few containers running and already used port 80 and 443.

I do have letsencrypt+nginx docker running as reverse proxy. Is it possible to just run the pi-hole docker (not use macvlan drive) and setup reverse proxy for pi-hole in nginx?

Appreciated any guide.

Using a guide for a specialized environment like Synology is going to cause you confusion.

You have mapped port 80 from the host to port 80 of the container. I don't think this is what you want. Follow the link I gave you to map the port on the host that you want to use in to the container.

thank you, I don't really have much background on this, I'll read up more.

if anyone know any other guide that specific for setup pi-hole docker on ubuntu and not use port 80 and 443, that will be great if you can point to me. port 80 and 443 already used by nginx docker.

thanks!

I've read and followed the guide on the github and also added port mapping, now it is seems running fine, with below port config:

    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "88:80/tcp"
      - "448:443/tcp"

I can access admin at http://ip:88/admin now. I manually set my laptop's dns to point to pihole, seems it is blocking ads.

I have nginx docker installed as reverse proxy, do I need to do anything for port 448 and 88 in order for the pihole to work on both http and https?

thanks!