origamiofficial / docker-pihole-unbound

A supercharged Pi-Hole docker container with Unbound built-in. [Auto Updates 🚀]
https://hub.docker.com/r/rlabinc/pihole-unbound
MIT License
56 stars 5 forks source link

pihole-unbound does not start with unbound volume mount #26

Closed jhomen368 closed 6 months ago

jhomen368 commented 6 months ago

This is a: Run Issue

Details with Docker log

/opt/unbound/etc/unbound/unbound.conf:345: error: cannot open include file '/opt/unbound/etc/unbound/a-records.conf': No such file or directory
/opt/unbound/etc/unbound/unbound.conf:346: error: cannot open include file '/opt/unbound/etc/unbound/srv-records.conf': No such file or directory
read /opt/unbound/etc/unbound/unbound.conf failed: 2 errors in configuration file
[1708986613] unbound[239:0] fatal error: Could not read config file: /opt/unbound/etc/unbound/unbound.conf. Maybe try unbound -dd, it stays on the commandline to see more errors, or

Related Issues

How to reproduce the issue

  1. Environment data

    • Operating System: Ubunutu (WSL)
    • Hardware: Personal Desktop
    • Kernel Architecture: x86/amd6
    • Docker Install Info and version:
    • Software source: Docker
    • Supplimentary Software: Docker Desktop
    • Hardware architecture: x86
    • Docker Image Tag: latest
  2. Troubleshooting Logs

Works:

docker run -d \
  --name pihole-unbound \
  -e TZ=Europe/London `#optional` \
  -p 53:53/tcp -p 53:53/udp \
  -p 80:80/tcp `#Pi-hole web interface port` \
  -e WEBPASSWORD='pihole' `#better to use single quotes` \
  -v "${PWD}/etc-pihole:/etc/pihole" \
  --restart=always \
  rlabinc/pihole-unbound:latest
CONTAINER ID   IMAGE                           COMMAND                  CREATED          STATUS                    PORTS                                                                NAMES
631fb3cec5ec   rlabinc/pihole-unbound:latest   "/s6-init /unbound.sh"   55 seconds ago   Up 49 seconds (healthy)   0.0.0.0:53->53/tcp, 0.0.0.0:80->80/tcp, 0.0.0.0:53->53/udp, 67/udp   pihole-unbound

Doesn't Work:

Leaves container in a reboot loop

docker run -d \
  --name pihole-unbound \
  -e TZ=Europe/London `#optional` \
  -p 53:53/tcp -p 53:53/udp \
  -p 80:80/tcp `#Pi-hole web interface port` \
  -e WEBPASSWORD='pihole' `#better to use single quotes` \
  -v "${PWD}/etc-pihole:/etc/pihole" \
  -v "${PWD}/opt/unbound/etc/unbound:/opt/unbound/etc/unbound" \
  --restart=always \
  rlabinc/pihole-unbound:latest
CONTAINER ID   IMAGE                           COMMAND                  CREATED              STATUS                          PORTS     NAMES
90667cb7268c   rlabinc/pihole-unbound:latest   "/s6-init /unbound.sh"   About a minute ago   Restarting (1) 10 seconds ago             pihole-unbound

Upload the unbound log file

unbound.log is a 0 byte file with no content

If the above debugging / fixes revealed any new information note it here. Add any other debugging steps you've taken or theories on root cause that may help.

Files seem to exist:

tree -p -u ${PWD}
[drwxr-xr-x jahomen ]  /home/jahomen/unbound-test
├── [drwxrwxr-x 999     ]  etc-pihole
│   ├── [-rw-r--r-- root    ]  adlists.list
│   ├── [-rw-r--r-- root    ]  custom.list
│   ├── [-rw-r--r-- 999     ]  dhcp.leases
│   ├── [-rw-r--r-- root    ]  dns-servers.conf
│   ├── [-rw-rw-r-- 999     ]  gravity.db
│   ├── [-rw-rw-r-- 999     ]  gravity_old.db
│   ├── [-rw-r--r-- root    ]  list.1.raw.githubusercontent.com.domains
│   ├── [-rw-r--r-- root    ]  list.1.raw.githubusercontent.com.domains.sha1
│   ├── [-rw-r--r-- root    ]  local.list
│   ├── [-rw-r--r-- root    ]  logrotate
│   ├── [drwxr-xr-x root    ]  migration_backup
│   │   └── [-rw-r--r-- root    ]  adlists.list
│   ├── [-rw-rw-r-- 999     ]  pihole-FTL.conf
│   ├── [-rw-rw-r-- 999     ]  pihole-FTL.db
│   ├── [-rw-r--r-- root    ]  setupVars.conf
│   ├── [-rw-r--r-- root    ]  setupVars.conf.update.bak
│   └── [-rw-r--r-- root    ]  versions
└── [drwxr-xr-x root    ]  opt
    └── [drwxr-xr-x root    ]  unbound
        └── [drwxr-xr-x root    ]  etc
            └── [drwxr-xr-x root    ]  unbound
                ├── [drwxr-xr-x root    ]  dev
                │   ├── [crw-rw-rw- root    ]  null
                │   ├── [crw-rw-rw- root    ]  random
                │   └── [crw-rw-rw- root    ]  urandom
                ├── [-rw-r--r-- root    ]  unbound.conf
                ├── [-rw-r--r-- jahomen ]  unbound.log
                └── [drwx------ jahomen ]  var
                    ├── [-rw-r--r-- root    ]  root.hints
                    └── [-rw-r--r-- root    ]  root.key

8 directories, 23 files

I also noticed this when I was trying to deploy the container into a Kubernetes cluster, at first I thought it was an issue with my manifests but when I tried it locally it gave me the same behavior. Once I defined the volume for unbound per the readme it starting rebooting and wouldn't come up. Am I missing something?

origamiofficial commented 6 months ago

You can create a directory with the name opt-unbound-etc-unbound & move everything from ${PWD}/opt/unbound/etc/unbound, just like you did with etc-pihole. And then use -v "${PWD}/opt-unbound-etc-unbound:/opt/unbound/etc/unbound"

jhomen368 commented 6 months ago

I was hoping that it would prepopulate default configurations. I just looked at the upstream unbound and it does the same thing so think this is the current expected behavior.

Pre-populating is a bit more difficult with my particular use case since I'm using a Kubernetes cluster with longhorn which does dynamic volume assignment. I'm just guessing but I probably have to spin pihole-unbound pod up, let it fail, down that pod leave leave the volume behind. Finally, mount that volume to another pod (unrelated to pihole) make the changes there detach that volume and then re-spin up the pihole-unbound pod. I'll figure something out thanks though!

origamiofficial commented 6 months ago

@jhomen368 I've misread the logs first. It correctly found the unbound.conf but seems the a-records.conf and srv-records.conf files are missing in your custom directory. Copy the missing files a-records.conf and srv-records.conf into the same directory as the unbound.conf file inside the container. Your issue will be fixed.

jhomen368 commented 6 months ago

I put in a feature request for the upstream unbound container https://github.com/MatthewVance/unbound-docker/issues/171.

origamiofficial commented 6 months ago

I'm working on it, soon image will be updated.

jhomen368 commented 6 months ago

Thanks! I really appreciate it

origamiofficial commented 6 months ago

Pushed hot fix updated image!