Setup on Pi in Docker - Bind Error

Hoping this is a simple issue that I just can't see. I'm trying to install Pi-hole on Raspberry Pi in Docker through docker-compose file. I receive the following error:

ERROR: for pihole Cannot start service pihole: driver failed programming external connectivity on endpoint pihole (c6ddeb24bf33865868ea14647e136d1e343ab7d4e149e866e04d840c4edab28a): Error starting userland proxy: listen udp 0.0.0.0:53: bind: address already in use

If I run:

sudo netstat -tulpn | grep LISTEN

I don't see any use of port 53

My docker-compose file:

pihole:
    container_name: pihole
    image: pihole/pihole:4.1_armhf
    ports:
      - 53:53/tcp
      - 53:53/udp
      - 67:67/udp
      - 80:80/tcp
      - 443:443/tcp
    environment:
      TZ: 'America/Chicago'
      WEBPASSWORD: 'redacted'
    volumes:
       - '/home/cshinn/docker_files/pihole:/etc/pihole'
       - '/home/cshinn/docker_files/pihole/dnsmasq.d:/etc/dnsmasq.d'
    # run `touch ./var-log/pihole.log` first unless you like errors
    # - './var-log/pihole.log:/var/log/pihole.log'
    dns:
      - 127.0.0.1
      - 1.1.1.1
    # 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

The readme documents the most common port 53 conflicts:

  • Port conflicts? Stop your server's existing DNS / Web services.
    • Ubuntu users especially may need to shut off dns on your docker server so it can run in the container on port 53

Thank! Just updated from 16.04 to 18.04.4 LTS and ran into this. If anyone comes across this running Ubuntu 17.04+:

$ sudo nano /etc/systemd/resolved.conf and change #DNSStubListener=yes to DNSStubListener=no (make sure you uncomment the line).
$ sudo service systemd-resolved restart

EDIT: Spoke too soon. This DOES allow the container to boot up, but it breaks DNS for the host.

EDIT 2: Okay, here are the steps that work for ME. You may have different needs.

$ sudo nano /etc/systemd/resolved.conf (make changes based on above)
$ sudo service systemd-resolved restart
$ sudo systemctl disable systemd-resolved.service
$ sudo systemctl stop systemd-resolved
$ sudo rm /etc/resolv.conf
$ sudo shutdown now -r

I haven't put much thought into this. You can probably actually skip the first two steps (I don't have a good way to verify), however following the above steps fixed it so that (1) the container will boot, and (2) the host can resolve domain names.

Had the same issue with Centos 8.1, same solution applied and it's now working properly, in theory if anything else is listening on this port, it's supposed to be turned off implicitly which seem to be an issue atm.

It was properly working with Centos 8.0 but no more in 8.1

I migrated from ubuntu to photon os for my docker host and ran into this issue again. Here are the steps I took on photon (I think they are the same on ubuntu, so you can probably ignore my original post). I'm not sure if this is the right way to do this, but this is what worked for me:

  1. systemctl stop systemd-resolved
  2. systemctl disable systemd-resolved
  3. nano /etc/resolv.conf
  4. manually add your nameserver IPs

If you stop systemd-resolved without manually setting your nameserver IPs, you won't be able to connect to hostnames via the host.

1 Like