Issues when restarting image jacklul/pihole

This (Solve DNS Resolution in Other Containers when using Docker pihole) works but container failed to automatically restart on raspberry pi restart with this error in journalctl -u docker

warning msg="Failed to allocate and map port 53-53: Error starting userland proxy: listen udp4 192.168.50.11:53: bind: cannot assign requested address"

docker-compose:

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: jacklul/pihole:latest
    ports:
      - "53:53/tcp"
      - "192.168.50.11:53:53/udp"
      - "67:67/udp"
      - "8080:80/tcp"
    environment:
      TZ: 'Asia/Karachi'
      ADMIN_EMAIL: email@gmail.com
      WEBPASSWORD: 'pass'
      WEBTHEME: 'default-dark'
      PIHOLE_DNS_: '192.168.50.1'
      FTLCONF_REPLY_ADDR4: '192.168.50.11'
      FTLCONF_REPLY_ADDR6: 'fe80::cc5a:101f:64:9db6'
    # Volumes store your data between container upgrades
    volumes:
      - './etc-pihole/:/etc/pihole/'
      - './etc-dnsmasq.d/:/etc/dnsmasq.d/'
      - './etc-pihole-updatelists/:/etc/pihole-updatelists/'
    #dns:
    #- 192.168.50.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

Note that I can manually restart it using docker-compose up -d but this was automatically restarting without IP bind (before applying this solution) because restart is set to unless-stopped.

Reason of using IP bind:

This works but container failed to automatically restart on raspberry pi restart with this error in journalctl -u docker

warning msg="Failed to allocate and map port 53-53: Error starting userland proxy: listen udp4 192.168.50.11:53: bind: cannot assign requested address"

docker-compose:

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: jacklul/pihole:latest
    ports:
      - "53:53/tcp"
      - "192.168.50.11:53:53/udp"
      - "67:67/udp"
      - "8080:80/tcp"
    environment:
      TZ: 'Asia/Karachi'
      ADMIN_EMAIL: email@gmail.com
      WEBPASSWORD: 'pass'
      WEBTHEME: 'default-dark'
      PIHOLE_DNS_: '192.168.50.1'
      FTLCONF_REPLY_ADDR4: '192.168.50.11'
      FTLCONF_REPLY_ADDR6: 'fe80::cc5a:101f:64:9db6'
    # Volumes store your data between container upgrades
    volumes:
      - './etc-pihole/:/etc/pihole/'
      - './etc-dnsmasq.d/:/etc/dnsmasq.d/'
      - './etc-pihole-updatelists/:/etc/pihole-updatelists/'
    #dns:
    #- 192.168.50.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

Note that I can manually restart it using docker-compose up -d but this was automatically restarting without IP bind (before applying this solution) because restart is set to unless-stopped

warning msg="Failed to allocate and map port 53-53: Error starting userland proxy: listen udp4 192.168.50.11:53: bind: cannot assign requested address"

This message shows the port 53 is already being used when Pi-hole container tries to restart.

When you restart your machine, there is something else binding to this port.
When docker starts, the port is already taken.
It could be a service on the host, or maybe another container starting before Pi-hole.

You need to find out which service is doing this.

You are not running the official Pi-hole Docker image.

If your issue persists, you should also consider contacting the maintainer of your specific image.

2 Likes

Issue also occurs with official pi image. This image has just some custom blocklists.

I am only running two containers. pihole and wireguard. both automatically starts on startup. As far as I know 53 port isn't used by anyone since I can manually start failed pihole using docker-compose up -d and it works without any issue.
Note that if I change "192.168.50.11:53:53/udp" to "53:53/udp" then it works as expected and restarts automatically on reboot. so this seems like a docker specific issue.

The message is telling port 53 is not available at restart.

There are 2 possibilities:

  • there is something using port 53 during the restart (not very likely, since you said there is no other services);
  • the network is still not fully available at the moment the container tries to restart. The port is not available and the warning is generated.

I cannot confirm this:
I am unable to recreate your observation with an official Pi-hole image.
Rebooting my RPi 3A will also bring up the Pi-hole container without a glitch.

It is not just adding some blocklists.

The docker file you've linked is utilising apt-get to install packages, and it then downloads an installation script that applies further alterations to the image, potentially establishing new or altered dependencies that a vanilla Pi-hole image doesn't have.

That said, I notice that your docker-compose only binds port 53 UDP to a specific address:

What is the reason for that?

I am able to successfully reboot my RPi even with those unusual bindings, but nevertheless:
Did you try to bind port 53 TCP to your 192.168.50.11 as well?

1 Like

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