Docker compus net host and port change for web interface

Hi,

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

Mike

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 https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "7979:80/tcp"
    environment:
      TZ: 'America/Chicago'
      WEBPASSWORD: 'replaced'
      ServerIP: '192.168.10.1'
      IPv6: 'false'
      DNSMASQ_LISTENING: 'local'
      INTERFACE: 'br0'
      DHCP_ACTIVE: 'true'
      DHCP_START: '192.168.10.3'
      DHCP_END: '192.168.10.251'
      DHCP_ROUTER: '192.168.10.1'
    # Volumes store your data between container upgrades
    volumes:
      - './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)
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    network_mode: host
    cap_add:
      - 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.