OpenWrt Docker Pi-Hole ERROR

Apologies for making a same topic like other but the original topic has been close. Link :
https://forum.openwrt.org/t/running-pihole-on-openwrt-x86-using-docker-tutorial-experiences/108144

All of the step above already followed but stuck at Pi-Hole container status always restarting. Looking at the logs of the container it said :

[cont-init.d] 10-fixroutes.sh: executing...
foreground: warning: unable to spawn /var/run/s6/etc/cont-init.d/10-fixroutes.sh: Permission denied
[cont-init.d] 10-fixroutes.sh: exited 127.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.

On the original link it said I have to use exec it ip -a on the container to check the IP but Docker cant do it because the container is not up yet ... Is there a solution for this ? Help :smiling_face_with_tear:

Hey @Deuxst , welcome! Not to worry about the whole new topic thing, its actually good that you have a referring link cause I got notified, amazing how this works seamlessly!

It seems the problem is with permissions, could you run the following and try starting pi-hole again: chmod 755 10-fixroutes.sh

If that didn't work, then run this and share it with me: ls -la 10-fixroutes.sh

Looks like I missed that in the tutorial so thanks for sharing.

Thanks for replying and helping @ahasbini .

I just tried
chmod 755 10-fixroutes.sh
and docker stop and start the image again but the logs still said

[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] 01-resolver-resolv: applying...
[fix-attrs.d] 01-resolver-resolv: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 05-changer-uid-gid.sh: executing...
[cont-init.d] 05-changer-uid-gid.sh: exited 0.
[cont-init.d] 10-fixroutes.sh: executing...
foreground: warning: unable to spawn /var/run/s6/etc/cont-init.d/10-fixroutes.sh: Permission denied
[cont-init.d] 10-fixroutes.sh: exited 127.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

Here's my 10-fixroutes.sh

root@OpenWrt:~# ls -la 10-fixroutes.sh
-rwxr-xr-x    1 root     root           197 Mar 24 02:09 10-fixroutes.sh

is the file position matter ? my 10-fixroutes.sh is at /root beside all the pihole directory..

The 10-fixroutes.sh is referenced in the docker-compose.yml file as such:

      - './pihole/etc-cont-init.d/10-fixroutes.sh:/etc/cont-init.d/10-fixroutes.sh'

In the steps of the tutorial this is how the file gets created (notice the correct path in the end):

echo '#!/usr/bin/with-contenv bash
set -e

echo "fixing routes"
ip route del default
ip route add default via 172.18.0.1
echo "done fixing routes"' >> ./pihole/etc-cont-init.d/10-fixroutes.sh

Can you mv 10-fixroutes.sh /pihole/etc-cont-init.d/ and try again? I think that should solve it.

A new problem just appear..
I moved 10-fixroutes.sh to ./pihole/etc-cont-init.d/10-fixroutes.sh and deleting the image and docker-compose up again.

It still keep restarting again and the logs is

[cont-init.d] executing container initialization scripts...
[cont-init.d] 05-changer-uid-gid.sh: executing...
[cont-init.d] 05-changer-uid-gid.sh: exited 0.
[cont-init.d] 10-fixroutes.sh: executing...
foreground: warning: unable to spawn /var/run/s6/etc/cont-init.d/10-fixroutes.sh: Exec format error
[cont-init.d] 10-fixroutes.sh: exited 127.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.

still having problem with the 10-fixroutes.sh :smiling_face_with_tear: ...

Ok then, lets remove 10-fixroutes.sh so container does not read it anymore, just comment out (add a hashtag at the beginning) the line in docker-compose.yml as such:

#      - './pihole/etc-cont-init.d/10-fixroutes.sh:/etc/cont-init.d/10-fixroutes.sh'

Then do docker-compose up -d pihole. This should be successful, if not share the output.

After that, run the command docker exec -it pihole ls -la /etc/cont-init.d/ and share with me the output.

Re compose up the pihole with

at docker-compose.yml still error. The logs was

[cont-init.d] 20-start.sh: executing...
 ::: Starting docker specific checks & setup for docker pihole/pihole
Failed to set capabilities on file `/usr/bin/pihole-FTL' (Operation not supported)
The value of the capability argument is not permitted for a file. Or the file is not a regular (non-symlink) file
ERROR: Unable to set capabilities for pihole-FTL. Cannot run as non-root.
       If you are seeing this error, please set the environment variable 'DNSMASQ_USER' to the value 'root'
[cont-init.d] 20-start.sh: exited 1.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.

And of course cannot

because the container is not up yet (always restarting because of the error).

That's beyond normal to me. What OpenWrt version are you running? What's the hardware? What's the docker version installed?

I'm using Raspberry Pi 3b+ running openwrt-21.02.1-bcm27xx-bcm2710-rpi-3-ext4-factory and the docker version was

root@OpenWrt:~# docker -v
Docker version 20.10.12, build e91ed57

should I start over everyhting ? or do you have a suggestion for the OpenWrt version and the Docker version ?

The hardware and versions seem very fine to me.

There seems to be a great deal of resemblance to your issue and the issue posted here though: https://github.com/pi-hole/docker-pi-hole/issues/963

Let's try using the same pihole version I have, it's a 6 months old version, though I haven't gotten to updating pihole but this version works great.

Take a backup and of the pihole directory and clean things up a bit:

# pihole-latest.tar is the backup, if you can share with me the output of the tar command for later reference
tar -cvf pihole-latest.tar pihole
# removing the pihole directory
rm -rf pihole
# recreating the folders as in the tutorial
mkdir -p ./pihole/etc-pihole/
mkdir -p ./pihole/etc-dnsmasq.d/
mkdir -p ./pihole/var-log/
mkdir -p ./pihole/etc-cont-init.d/

Modify the line in the docker-compose.yml file and try to start pihole again, change

    image: pihole/pihole:latest

to

    image: pihole/pihole:2021.09

And try again, if this works then we can continue with the steps in the tutorial to fully setup pihole.

Here's the .tar file of my pihole directory

https://drive.google.com/file/d/1bmvKSKjE1RDty5C8M2_1ZBTB5EGBUlXu/view?usp=sharing

And thank god the container was healthy and running but then I check the log it was

lighttpd: no process found
Starting lighttpd
2022-04-08 19:02:00: (server.c.750) opening errorlog '/var/log/lighttpd/error.log' failed: No such file or directory
2022-04-08 19:02:00: (server.c.1461) Opening errorlog failed. Going down.
Stopping lighttpd
lighttpd: no process found

over and over again. what should I do next ?

ps : I'm so sorry for my bad English and if my responses is hard to understand

1 Like

That's great news actually, so indeed the problem you were experiencing was related to the github issue shared.

Does the pihole stay running after the error? Can you share the full output of the logs?

Not to worry its actually great.

The container status was healthy but the logs is just repeat of lighthttpd error..

Here is the container status

root@OpenWrt:~# docker ps
CONTAINER ID   IMAGE                   COMMAND      CREATED       STATUS                    PORTS     NAMES
e71d20fcd78c   pihole/pihole:2021.09   "/s6-init"   2 hours ago   Up 33 seconds (healthy)             pihole

But the logs is

Starting lighttpd
2022-04-08 21:00:59: (server.c.750) opening errorlog '/var/log/lighttpd/error.log' failed: No such file or directory
2022-04-08 21:00:59: (server.c.1461) Opening errorlog failed. Going down.
Stopping lighttpd
lighttpd: no process found
Starting lighttpd
2022-04-08 21:01:00: (server.c.750) opening errorlog '/var/log/lighttpd/error.log' failed: No such file or directory
2022-04-08 21:01:00: (server.c.1461) Opening errorlog failed. Going down.
Stopping lighttpd
lighttpd: no process found
Starting lighttpd
2022-04-08 21:01:01: (server.c.750) opening errorlog '/var/log/lighttpd/error.log' failed: No such file or directory
2022-04-08 21:01:01: (server.c.1461) Opening errorlog failed. Going down.
Stopping lighttpd
lighttpd: no process found

repeated of httpd error..

Could you run the following and share the output:

docker exec -it pihole ls -la /var/log/
docker exec -it pihole ls -la /var/log/lighttpd
ls -la ./pihole/var-log/

There is no such file or directory on /var/log/lighttpd ..

root@OpenWrt:~# docker exec -it pihole ls -la /var/log/
total 132
drwxr-xr-x 3 root   root    4096 Apr  8 19:00 .
drwxr-xr-x 1 root   root    4096 Sep 12  2021 ..
drwxr-xr-x 2 pihole pihole  4096 Apr  8 19:00 pihole
-rw-r--r-- 1 pihole pihole 35443 Apr  8 21:43 pihole-FTL.log
-rw-r--r-- 1 pihole pihole 71389 Apr  8 21:43 pihole.log
-rw-r--r-- 1 root   root    1293 Apr  8 19:00 pihole_updateGravity.log
root@OpenWrt:~# docker exec -it pihole ls -la /var/log/lighttpd
ls: cannot access '/var/log/lighttpd': No such file or directory
root@OpenWrt:~# ls -la ./pihole/var-log/
drwxr-xr-x    3 root     root          4096 Apr  8 12:00 .
drwxr-xr-x    5 root     root          4096 Apr  8 12:00 ..
drwxr-xr-x    2 999      999           4096 Apr  8 12:00 pihole
-rw-r--r--    1 999      999          35443 Apr  8 14:43 pihole-FTL.log
-rw-r--r--    1 999      999          72155 Apr  8 14:43 pihole.log
-rw-r--r--    1 root     root          1293 Apr  8 12:00 pihole_updateGravity.log

Run the following:

mkdir -p ./pihole/var-log/lighttpd
chown 33:33 ./pihole/var-log/lighttpd

This part seems missed in the tutorial

1 Like

The container was running and it the lighthttpd error fixed. Continuing step from the original post @ahasbini you've made..
Ping the container , work

root@OpenWrt:~# ping 192.168.1.3
PING 192.168.1.3 (192.168.1.3): 56 data bytes
64 bytes from 192.168.1.3: seq=0 ttl=64 time=0.356 ms
64 bytes from 192.168.1.3: seq=1 ttl=64 time=0.260 ms
64 bytes from 192.168.1.3: seq=2 ttl=64 time=0.258 ms

--- 192.168.1.3 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss

nslookup the container, nope..

root@OpenWrt:~# nslookup openwrt.org 192.168.1.3
;; connection timed out; no servers could be reached

executing docker exec -it pihole ip a

root@OpenWrt:~# docker exec -it pihole ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
8: eth0@if4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:c0:a8:01:03 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.1.3/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
9: eth1@if10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:ac:12:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.18.0.2/16 brd 172.18.255.255 scope global eth1
       valid_lft forever preferred_lft forever

Now is the time for dealing the 10-fixroutes.sh and the SetupVars.conf ? how to do it ?
And also the last nslookup didn't work too and of course http://192.168.1.3/admin cant be reached..

root@OpenWrt:~# nslookup $root.lan 192.168.1.3
;; connection timed out; no servers could be reached

That's great news, we're very close. Let's include 10-fixroutes.sh and then continue with the tutorial, apply the following:

  • Uncomment the following line in docker-compose.yml (remove the # at the beginning):
      - './pihole/etc-cont-init.d/10-fixroutes.sh:/etc/cont-init.d/10-fixroutes.sh'
  • Run the following:
echo '#!/usr/bin/with-contenv bash
set -e

echo "fixing routes"
ip route del default
ip route add default via 172.18.0.1
echo "done fixing routes"' >> ./pihole/etc-cont-init.d/10-fixroutes.sh
chmod 755 ./pihole/etc-cont-init.d/10-fixroutes.sh
  • Continue with the tutorial from the step Start PiHole and finalize its setup. If you've already done the changes from some of the steps, then you can skip them.

Let me know if you faced any problems.

Removing # from .yml file > creating 10-fixroutes.sh and chmod > compose up again > creating the setupVars.conf and the logs was ..

[s6-finish] sending all processes the KILL signal and exiting.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] 01-resolver-resolv: applying...
[fix-attrs.d] 01-resolver-resolv: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 10-fixroutes.sh: executing...
foreground: warning: unable to spawn /var/run/s6/etc/cont-init.d/10-fixroutes.sh: Exec format error
[cont-init.d] 10-fixroutes.sh: exited 127.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.

Its the 10-fixroutes again ..

root@OpenWrt:~/pihole/etc-cont-init.d# ls -la
drwxr-xr-x    2 root     root          4096 Apr 10 13:23 .
drwxr-xr-x    6 root     root          4096 Apr 10 13:22 ..
-rwxr-xr-x    1 root     root           147 Apr 10 13:28 10-fixroutes.sh

root@OpenWrt:~/pihole/etc-cont-init.d# cat 10-fixroutes.sh
echo '#!/usr/bin/with-contenv bash
set -e

echo "fixing routes"
ip route del default
ip route add default via 172.18.0.1
echo "done fixing routes"

How to fix it ?

Different error, this time the file is sort of corrupted or incorrect. This is how the 10-fixroutes.sh should be:

#!/usr/bin/with-contenv bash
set -e

echo "fixing routes"
ip route del default
ip route add default via 172.18.0.1
echo "done fixing routes"

In your file you have an echo ' at the beginning of the file which is not right. Fix your 10-fixroutes.sh and try again.