cant run pihole in docker-compose

Viewed 5311

im new here and also a newbie in Homeautomatisation with my Raspi 3 ^^

Im trying to get Pihole running in Docker-compose but i get this error message everytime i want to start it.

ERROR: for pihole Cannot start service pihole: driver failed programming external connectivity on endpoint pihole (995a633f1e1fa2e0ec3ebde4065ee7c6ab5dc82452adf2ffcf10d3113295a369): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use

ERROR: for pihole Cannot start service pihole: driver failed programming external connectivity on endpoint pihole (995a633f1e1fa2e0ec3ebde4065ee7c6ab5dc82452adf2ffcf10d3113295a369): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use


MY CONFIG


This is my docker-compose.yml configuration like on github

        version: "3"
    
    services:
      pihole:
        container_name: pihole
        image: pihole/pihole:latest
        ports:
          - "53:53/tcp"
          - "53:53/udp"
          - "67:67/udp"
          - "80:80/tcp"
          - "443:443/tcp"
          - 8080:80
        environment:
          TZ: 'Europe/Berlin'
          WEBPASSWORD: 'myPassword'
        # Volumes store your data between container upgrades
        volumes:
          - './etc-pihole/:/etc/pihole/'
          - './etc-dnsmasq.d/:/etc/dnsmasq.d/'
        # Recommended but not required (DHCP needs NET_ADMIN)
        #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
        cap_add:
          - NET_ADMIN
        restart: unless-stopped

My Troubleshooting


When i run sudo lsof -iTCP -sTCP:LISTEN -P -n +c 10 i get that:

COMMAND      PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd         543 root    3u  IPv4  18484      0t0  TCP *:22 (LISTEN)
sshd         543 root    4u  IPv6  18486      0t0  TCP *:22 (LISTEN)
xrdp-sesma   592 root    7u  IPv6  18529      0t0  TCP [::1]:3350 (LISTEN)
xrdp         603 xrdp   11u  IPv6  18545      0t0  TCP *:3389 (LISTEN)
docker-pro  2877 root    4u  IPv6  25751      0t0  TCP *:4357 (LISTEN)
docker-pro  7386 root    4u  IPv6  36076      0t0  TCP *:8884 (LISTEN)
docker-pro  7400 root    4u  IPv6  34359      0t0  TCP *:8883 (LISTEN)
docker-pro  7415 root    4u  IPv6  36124      0t0  TCP *:1884 (LISTEN)
docker-pro  7428 root    4u  IPv6  35103      0t0  TCP *:1883 (LISTEN)
docker-pro  9507 root    4u  IPv6  42104      0t0  TCP *:9050 (LISTEN)
spotifyd   10195 root   18u  IPv4  43347      0t0  TCP *:46551 (LISTEN)
python3    11346 root   17u  IPv4  48294      0t0  TCP *:8123 (LISTEN)
ttyd       11498 root   12u  IPv4  48157      0t0  TCP 172.30.32.1:62369 (LISTEN)
sshd       11499 root    3u  IPv4  48140      0t0  TCP *:222 (LISTEN)
sshd       11499 root    4u  IPv6  48141      0t0  TCP *:222 (LISTEN)
httpd      13801 root    4u  IPv6  53868      0t0  TCP *:80 (LISTEN)
httpd      13801 root    6u  IPv6  53872      0t0  TCP *:443 (LISTEN)
httpd      13802 root    4u  IPv6  53868      0t0  TCP *:80 (LISTEN)
httpd      13802 root    6u  IPv6  53872      0t0  TCP *:443 (LISTEN)
httpd      13803 root    4u  IPv6  53868      0t0  TCP *:80 (LISTEN)
httpd      13803 root    6u  IPv6  53872      0t0  TCP *:443 (LISTEN)
httpd      13804 root    4u  IPv6  53868      0t0  TCP *:80 (LISTEN)
httpd      13804 root    6u  IPv6  53872      0t0  TCP *:443 (LISTEN)
httpd      13907 root    4u  IPv6  53868      0t0  TCP *:80 (LISTEN)
httpd      13907 root    6u  IPv6  53872      0t0  TCP *:443 (LISTEN)

i tried to stop the systemd-resolved service but i did not get any answer in shell i've used this commands:

sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved 

Than i removed the resolv config with: rm /etc/resolv.conf

and recreate it with: nano /etc/resolv.conf

nameserver 127.0.0.1
nameserver 1.1.1.1
nameserver 222.222

I saved it with crtl+x and restarted the whole system by sudo reboot

afer retrying to start pihole with: docker-compose -f /opt/containers/pi-hole/docker-compose.yml up -d

i've got the same issue as you can see in the upper part of my request.

How can i fix it?
Thanks for your help !

2 Answers

hope your well. Excuse me but I could be mistaken but Docker runs in a separate network by default called a docker bridge network, which makes DHCP want to serve addresses to that network and not your LAN network where you probably want it. Can I suggest looking at the document at as I believe it presents option to help you move forward.

https://docs.pi-hole.net/docker/DHCP/

You've configured pihole to listen on port 80 on the host, mapped to port 80 in the container:

- "80:80/tcp"

You also have a httpd server listening on port 80:

httpd      13801 root    4u  IPv6  53868      0t0  TCP *:80 (LISTEN)

Hence the error indicating port 80 is in use:

Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use

To resolve this, configure pihole to map a different port (you've already set port 8080, but left the port 80 mapping), or stop httpd.

Related