Can't access pi-hole web UI with network_mode: host

Hi!

Expected Behaviour:

I'm running pi-hole in Docker - Ubuntu 22.04.

I'm unable to access pi-hole web UI when using network_mode: host, it works when using the manual port mapping.

This is my config:

version: "3"

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    network_mode: "host"
    cap_add:
      - NET_ADMIN
    environment:
      TZ: 'America/Montevideo'
      WEBPASSWORD: 'some-pass'
      INTERFACE: eno1
      ServerIP: '192.168.0.2'
      WEB_PORT: "850"
    volumes:
      - '/home/santiago/selfhost/pi-hole/etc-pihole:/etc/pihole'
      - '/home/santiago/selfhost/pi-hole/etc-dnsmasq.d:/etc/dnsmasq.d'
    restart: unless-stopped

Actual Behaviour:

I should be able to access pi-hole web UI.

Debug Token:

https://tricorder.pi-hole.net/y0IwSrNW/

Did you manually edit /etc/lighttpd/lighttpd.conf?

Try to remove

$SERVER["socket"] == "127.0.0.1:850" {}

Then restart lighttpd running service lighttpd restart (inside the container).

Hey, thanks for your response!

I didn't manually edited that file, that port comes from WEB_PORT: "850" environment variable.
If I remove that variable and recreate the container it uses the port 80, but the web ui is still missing.

The new debug token with that change is https://tricorder.pi-hole.net/ipK3uutD

What's the exact URL you are using to access the web interface?

Without the WEB_PORT: http://192.168.0.2/admin/index.php
With the WEB_PORT: http://192.168.0.2:850/admin/index.php

The IP is 192.168.0.2 Indeed, I can access other frontends hosted on the same machine (Sonarr, Radarr, etc). Maybe I have to forward the ports?

It works if instead of network_mode: "host" I use:

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

This could be a combination of port conflicts over port 80 with other webservers running on your system and your usage of a privileged port (<1023) as an alternate.

What happens if you try using one of the alternate HTTP ports (8008 or 8080, provided your other webservers are not using those already), or one of the ports from 8083 to 8087?

I already checked if the ports were being used, but it's not the case. What's weird is that if I do the port mapping manually it works. What are all the ports that pi-hole opens when doing network_mode: "host"?

Btw: I just tried with 8087 and have the same issue.
Generated a new debug with this just in case it's useful.
https://tricorder.pi-hole.net/NARS62Os/

The image only exposes ports 80, 53 and 67 (the network mode doesn't matter):

Hey, I found the problem, I wasn't forwarding the ports, after running sudo ufw allow 67, 53 and 80 it started working. I don't know why this wasn't required by the ports: 80:80/tcp, but I may be missing a Docker/Linux concept.

Thanks!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.