pi-hole / docker-pi-hole

Pi-hole in a docker container
https://pi-hole.net
Other
8.58k stars 1.13k forks source link

WEB_PORT not being applied? #1139

Closed PromoFaux closed 2 years ago

PromoFaux commented 2 years ago

I'm actually experiencing something very similar. here's my docker-compose:

version: "3"

# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
services:
  cloudflared:
    container_name: cloudflared
    image: cloudflare/cloudflared:latest
    command: proxy-dns
    restart: unless-stopped
    environment:
      - "TUNNEL_DNS_UPSTREAM=https://1.1.1.1/dns-query,https://1.0.0.1/dns-query,https://9.9.9.9/dns-query,https://149.112.112.9/dns-query"

      # Listen on an unprivileged port
      - "TUNNEL_DNS_PORT=5053"

      # Listen on all interfaces
      - "TUNNEL_DNS_ADDRESS=0.0.0.0"
    ports:
      - "5053:5053/udp"
    networks:
       piholenet:
         ipv4_address: '172.19.0.3'

  pihole:
    container_name: pihole
    image: pihole/pihole:latest

    network_mode: host

    environment:
      TZ: 'America/Boise'
      WEB_PORT: 8081

    # Volumes store your data between container upgrades
    volumes:
      - './etc-pihole:/etc/pihole'
      - './etc-dnsmasq.d:/etc/dnsmasq.d'
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    cap_add:
      - NET_ADMIN # Required if you are using Pi-hole as your DHCP server, else not needed
    restart: unless-stopped
networks:
  piholenet:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.19.0.0/24

In this configuration, I'm forwarding through CloudFlared, I'm also running in host network mode because I'm doing DHCP and that was easiest.

I did create a static IP address through piholenet for CloudFlared, but pihole isn't using it, so I don't think it's related. WEB_PORT appears to be completely ignored, no matter what I set that value to, Pihole listens on port 80.

Originally posted by @ryancastro in https://github.com/pi-hole/docker-pi-hole/issues/1134#issuecomment-1179623714

PromoFaux commented 2 years ago

Question from @PromoFaux to @ryancastro

@ryancastro likely a different issue in your case.

Inside your running pihole container, what is the value of the server.port setting in /etc/lighttpd/lighttpd.conf ?

Reply:

server.port = 80

A nice, static port 80.

If it's unrelated, I'll hope not to muddy this original issue up. Maybe I jumped the gun and assumed it was just the same, since it was on :latest with presumably same symptoms. Thoughts? I appreciate the quick help, @PromoFaux !

PromoFaux commented 2 years ago

The other issue is a network configuration issue by the looks of things, this may actually be a bug.. though might take me a while to get to the bottom of it

It's not something I have come across before because I don't use HOST mode for my network (rather, macvlan)

Relevant code:

https://github.com/pi-hole/docker-pi-hole/blob/7e69551be1b76d175fffc1b8c53733e74ee82520/start.sh#L187

https://github.com/pi-hole/docker-pi-hole/blob/7e69551be1b76d175fffc1b8c53733e74ee82520/bash_functions.sh#L242-L263

Do you see Custom WEB_PORT set to in the startup log of you container?

PromoFaux commented 2 years ago

That said - It is working OK for me.. 🙃

image

Edit:

And the same using your compose file above:

image

ryancastro commented 2 years ago

So I just checked - I had a pihole image pulled from 4 weeks ago (whatever that was), and that was my :latest. I just pulled down the latest image and tried again... works!

Adam - sorry for the trouble. I'm not new to pihole but I'm very new to docker. I really appreciate your amazingly fast responses. It looks like I am in good shape now. Thank you very, very much for taking the time.

PromoFaux commented 2 years ago

That whole section of code has not been touched for 5 years, so... who knows?! Computers do weird stuff sometimes ;)

image

nettybun commented 6 months ago

To anyone searching this in the future: if the basic_install.sh fails during the container's startup then the WEB_HOST code will never be reached.

In my case I was seeing Operation not permitted (rootless podman)

$ podman logs pihole
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service cron: starting
s6-rc: info: service cron successfully started
s6-rc: info: service _uid-gid-changer: starting
s6-rc: info: service _uid-gid-changer successfully started
s6-rc: info: service _startup: starting
  [i] Starting docker specific checks & setup for docker pihole/pihole
  [i] Setting capabilities on pihole-FTL where possible
  [i] Applying the following caps to pihole-FTL:
        * CAP_CHOWN
        * CAP_NET_BIND_SERVICE
  [i] Ensuring basic configuration by re-running select functions from basic-install.sh

  [i] Installing configs from /etc/.pihole...
  [i] Existing dnsmasq.conf found... it is not a Pi-hole file, leaving alone!
  [✓] Installed /etc/dnsmasq.d/01-pihole.conf
  [✓] Installed /etc/dnsmasq.d/06-rfc6761.conf
/etc/.pihole/automated install/basic-install.sh: line 1362: /etc/pihole/dns-servers.conf: Permission denied
s6-rc: info: service _startup successfully started
s6-rc: info: service pihole-FTL: starting
s6-rc: info: service pihole-FTL successfully started
s6-rc: info: service lighttpd: starting
s6-rc: info: service lighttpd successfully started
s6-rc: info: service _postFTL: starting
s6-rc: info: service _postFTL successfully started
s6-rc: info: service legacy-services: starting
  Checking if custom gravity.db is set in /etc/pihole/pihole-FTL.conf
s6-rc: info: service legacy-services successfully started
chown: changing ownership of '/etc/pihole/dhcp.leases': Operation not permitted
chown: changing ownership of '/etc/pihole': Operation not permitted
chmod: changing permissions of '/etc/pihole/dhcp.leases': Operation not permitted
2024-04-28 20:11:23: network.c.369) can't bind to socket: 0.0.0.0:80: Address already in use
Stopping lighttpd
lighttpd: no process found

Notice how the permission error was about https://github.com/pi-hole/pi-hole/blob/master/automated%20install/basic-install.sh#L1362 ...

Unfortunately everything else seems fine - this doesn't crash the container. I wish it would have.

Anyway somehow the -v ./path/to/pihole:/etc/pihole/ permissions were wrong. Doing chown $USER:$USER -R ./path/to/pihole and a restart fixed it.

Hope this helps someone else!