Docker compus net host and port change for web interface


how can I change the port for the web interface while using net host on docker compose?


See WEB_PORT in Docker Pi-hole's Environment Variables section.

I tried that already, but it only changes, if I am using anything else than net host.

Please share your Docker configuration with us, i.e. your docker-compose.yml or your your docker run command.

version: "3"

# More info at and
    container_name: pihole
    image: pihole/pihole:latest
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "7979:80/tcp"
      TZ: 'America/Chicago'
      WEBPASSWORD: 'replaced'
      ServerIP: ''
      IPv6: 'false'
      DNSMASQ_LISTENING: 'local'
      INTERFACE: 'br0'
      DHCP_ACTIVE: 'true'
      DHCP_START: ''
      DHCP_END: ''
      DHCP_ROUTER: ''
    # Volumes store your data between container upgrades
      - './etc-pihole/:/etc/pihole/'
      - './etc-dnsmasq.d/:/etc/dnsmasq.d/'
    #  - '/home/micha/container/pihole/con.conf:/etc/lighttpd/lighttpd.conf:ro'
    # Recommended but not required (DHCP needs NET_ADMIN)
    network_mode: host
      - NET_ADMIN

That is the configuration I am currently using. I think since I am using network_mode: host, the complete part with the ports is ignored.

I tried putting WEB_PORT: 7979 in it, no difference.

I tried to put WEB_PORT: 7979 in etc-pihole/setupVars.conf, no difference.

I tried to replace the lighttpd.conf with the same file, just changed the ports, but pihole won´t start.

If you just added WEB_PORT to the environment and left the ports as 7979:80 then you changed lighttpd inside the running container from port 80 to port 7979 and then told Docker to take port 7979 and map it to 80 inside the container, which now doesn't exist since you told lighttpd to run on port 7979.

1 Like

In host mode, there is no immediate need to map ports - Docker will allow its host to access all of a container's exposed ports (without publishing them through a ports section).

If you still do that along with using WEB_PORT, what you observed and Dan described is what happens.

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