jacklul / pihole-updatelists

Update Pi-hole's lists from remote sources easily
MIT License
1.44k stars 84 forks source link

Issue with creating custom docker file #106

Closed mwatz1234 closed 2 years ago

mwatz1234 commented 2 years ago

background: My goal is to combine pihole-updatelists and testdasi/pihole-dot-doh. I forked over pihole-dot-doh to create a custom Dockerfile and added the lines to needed. RUN apt-get update && apt-get install -Vy php-cli php-sqlite3 php-intl php-curl wget RUN wget -O - https://raw.githubusercontent.com/jacklul/pihole-updatelists/master/install.sh | bash /dev/stdin docker

When I run docker compose it fails with an error that looks like pihole-updatelists cron job never got created. pihole | '/etc/pihole-updatelists.conf' -> '/etc/pihole-updatelists/pihole-updatelists.conf' pihole | mv: cannot stat '/etc/cron.d/pihole-updatelists': No such file or directory pihole | [cont-init.d] 30-pihole-updatelists.sh: exited 1.

Is there a better way to see where the issue is? Or I am creating the custom docker incorrectly? BTW, i had to add installing wget, as the wget command to get the install file fails as wget isnt installed

Longer Log below

pihole  | [s6-init] making user provided files available at /var/run/s6/etc...exited 0.
pihole  | [s6-init] ensuring user provided files have correct perms...exited 0.
pihole  | [fix-attrs.d] applying ownership & permissions fixes...
pihole  | [fix-attrs.d] 01-resolver-resolv: applying...
pihole  | [fix-attrs.d] 01-resolver-resolv: exited 0.
pihole  | [fix-attrs.d] done.
pihole  | [cont-init.d] executing container initialization scripts...
pihole  | [cont-init.d] 05-changer-uid-gid.sh: executing...
pihole  | [cont-init.d] 05-changer-uid-gid.sh: exited 0.
pihole  | [cont-init.d] 20-start.sh: executing...
pihole  |  ::: Starting docker specific checks & setup for docker pihole/pihole
pihole  |
pihole  |   [i] Installing configs from /etc/.pihole...
pihole  |   [i] Existing dnsmasq.conf found... it is not a Pi-hole file, leaving alone!
  [✓] Installed /etc/dnsmasq.d/01-pihole.conf
  [✓] Installed /etc/dnsmasq.d/06-rfc6761.conf
pihole  | Creating empty /etc/pihole/setupVars.conf file.
pihole  | Applying pihole-FTL.conf setting REPLY_ADDR4=192.168.xxx.xxx
pihole  | Setting DNS servers based on PIHOLE_DNS_ variable
pihole  | Setting Web Theme based on WEBTHEME variable, using value lcars
pihole  |   [✓] New password set
pihole  | DNSMasq binding to default interface: eth0
pihole  | Added ENV to php:
pihole  |                       "TZ" => "America/Los_Angeles",
pihole  |                       "PIHOLE_DOCKER_TAG" => "2022.04.3",
pihole  |                       "PHP_ERROR_LOG" => "/var/log/lighttpd/error.log",
pihole  |                       "ServerIP" => "0.0.0.0",
pihole  |                       "CORS_HOSTS" => "",
pihole  |                       "VIRTUAL_HOST" => "0.0.0.0",
pihole  | Using IPv4 and IPv6
pihole  | ::: setup_blocklists now setting default blocklists up:
pihole  | ::: TIP: Use a docker volume for /etc/pihole/adlists.list if you want to customize for first boot
pihole  | ::: Blocklists (/etc/pihole/adlists.list) now set to:
pihole  | https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
pihole  | ::: Testing lighttpd config: Syntax OK
pihole  | ::: All config checks passed, cleared for startup ...
pihole  | ::: Enabling Query Logging
pihole  |   [i] Enabling logging...
  [✓] Logging has been enabled!
pihole  |  ::: Docker start setup complete
pihole  |   Checking if custom gravity.db is set in /etc/pihole/pihole-FTL.conf
pihole  |   Pi-hole version is v5.10 (Latest: v5.10)
pihole  |   AdminLTE version is v5.12 (Latest: v5.12)
pihole  |   FTL version is v5.15 (Latest: v5.15)
pihole  |   Container tag is: 2022.04.3
pihole  | [cont-init.d] 20-start.sh: exited 0.
pihole  | [cont-init.d] 30-pihole-updatelists.sh: executing...
pihole  | copied '/etc/pihole-updatelists.conf' -> '/etc/pihole-updatelists/pihole-updatelists.conf'
pihole  | removed '/etc/pihole-updatelists.conf'
pihole  | '/etc/pihole-updatelists.conf' -> '/etc/pihole-updatelists/pihole-updatelists.conf'**
**pihole  | mv: cannot stat '/etc/cron.d/pihole-updatelists': No such file or directory**
**pihole  | [cont-init.d] 30-pihole-updatelists.sh: exited 1.
pihole  | [cont-finish.d] executing container finish scripts...
pihole  | [cont-finish.d] done.
pihole  | [s6-finish] waiting for services.
pihole  | [s6-finish] sending all processes the TERM signal.
pihole  | [s6-finish] sending all processes the KILL signal and exiting.
pihole exited with code 1
jacklul commented 2 years ago

I would check if there is a following log entry while building the image: Created crontab (/etc/cron.d/pihole-updatelists) It should be at the bash /dev/stdin docker step.

I've updated main Dockerfile to install wget as well.

mwatz1234 commented 2 years ago

Here is the log file section of of building the image. I see it creating the cron tab.

2022-05-30T17:10:05.2748957Z #29 [linux/arm64 5/6] RUN wget -O - https://raw.githubusercontent.com/jacklul/pihole-updatelists/master/install.sh | sudo bash /dev/stdin docker
2022-05-30T17:10:05.2749667Z #0 0.257 --2022-05-30 17:10:04--  https://raw.githubusercontent.com/jacklul/pihole-updatelists/master/install.sh
2022-05-30T17:10:05.2750332Z #0 0.424 Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.110.133, 185.199.109.133, ...
2022-05-30T17:10:05.2751065Z #0 0.456 Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.
2022-05-30T17:10:05.2751464Z #0 0.558 HTTP request sent, awaiting response... 200 OK
2022-05-30T17:10:05.2751744Z #0 0.570 Length: 7624 (7.4K) [text/plain]
2022-05-30T17:10:05.2752069Z #0 0.573 Saving to: 'STDOUT'
2022-05-30T17:10:05.2752288Z #0 0.576 
2022-05-30T17:10:05.2752533Z #0 0.576      0K .......                                               100% 1.63M=0.004s
2022-05-30T17:10:05.2752772Z #0 0.590 
2022-05-30T17:10:05.2753113Z #0 0.591 2022-05-30 17:10:05 (1.63 MB/s) - written to stdout [7624/7624]
2022-05-30T17:10:05.2753465Z #0 0.591 
2022-05-30T17:10:06.1078293Z #29 1.507 2022-05-30 17:10:06 URL:https://raw.githubusercontent.com/jacklul/pihole-updatelists/master/pihole-updatelists.php [92718/92718] -> "/usr/local/sbin/pihole-updatelists" [1]
2022-05-30T17:10:06.2581472Z #29 1.550 mode of '/usr/local/sbin/pihole-updatelists' changed from 0644 (rw-r--r--) to 0755 (rwxr-xr-x)
2022-05-30T17:10:06.5585518Z #29 1.895 2022-05-30 17:10:06 URL:https://raw.githubusercontent.com/jacklul/pihole-updatelists/master/pihole-updatelists.conf [669/669] -> "/etc/pihole-updatelists.conf" [1]
2022-05-30T17:10:06.8278537Z #29 2.227 2022-05-30 17:10:06 URL:https://raw.githubusercontent.com/jacklul/pihole-updatelists/master/pihole-updatelists.bash [1152/1152] -> "/etc/bash_completion.d/pihole-updatelists" [1]
2022-05-30T17:10:06.9373727Z #29 2.295 Created crontab (/etc/cron.d/pihole-updatelists)
2022-05-30T17:10:06.9374223Z #29 2.336 mkdir: created directory '/etc/pihole-updatelists'
2022-05-30T17:10:07.0883721Z #29 2.342 Installed container startup script (/etc/cont-init.d/30-pihole-updatelists.sh)
2022-05-30T17:10:07.0884101Z #29 DONE 2.4s
jacklul commented 2 years ago

It looks like it should be there, does /etc/cron.d/ even exist in the container?

mwatz1234 commented 2 years ago

Since the container stopped, had to look into how to navigate the file system of a stopped container.
I only see one file listed in the /etc/cron.d/ folder gravity-on-boot

jacklul commented 2 years ago

It seems like this is an issue with testdasi/pihole-dot-doh image directly (it uses testdasi/pihole-base-plus as a base instead of pihole/pihole) and that's where the issue might be. I just checked and sample Dockerfile from this repository builds and starts image correctly.

mwatz1234 commented 2 years ago

I can use the testdasi/pihole-dot-doh image and that image starts correctly, I forked that repo and modified the docker file. I am not sure if the issue is becuase its nested docker files to pihole/pihole. As testdasi/pihole-base-plus uses pihole/pihole:latest and my fork version is using base-plus.

jacklul commented 2 years ago

Maybe testdasi/pihole-dot-doh is removing /etc/cron.d/pihole* files in startup script or something? There isn't much I can do here since the install log you posted shows correct install and that the file was created.

mwatz1234 commented 2 years ago

So I gave up on trying to get pihole, doh, dot, and updlists in one docker. I tried to use your image, and it fails with the same error (i deleted everything in the 'etc' folder so nothing should interfere. This is running on a raspbery pi the latest bullseye 64bit.

The error section: pihole | [cont-init.d] 20-start.sh: exited 0. pihole | [cont-init.d] 30-pihole-updatelists.sh: executing... pihole | copied '/etc/pihole-updatelists.conf' -> '/etc/pihole-updatelists/pihole-updatelists.conf' pihole | removed '/etc/pihole-updatelists.conf' pihole | '/etc/pihole-updatelists.conf' -> '/etc/pihole-updatelists/pihole-updatelists.conf' pihole | mv: cannot stat '/etc/cron.d/pihole-updatelists': No such file or directory pihole | [cont-init.d] 30-pihole-updatelists.sh: exited 1. pihole | [cont-finish.d] executing container finish scripts... pihole | [cont-finish.d] done. pihole | [s6-finish] waiting for services. pihole | [s6-finish] sending all processes the TERM signal. pihole | [s6-finish] sending all processes the KILL signal and exiting. pihole exited with code 1

my docker compose file contains the following

version: '3.0'

services:
  pihole:
    container_name: pihole
    image: jacklul/pihole:latest
    hostname: pihole
    domainname: pihole.local
    ports:
      - "443:443/tcp"
      - "53:53/tcp"
      - "53:53/udp"
      - "80:80/tcp"
    environment:
      - FTLCONF_REPLY_ADDR4=192.168.2.19
      - TZ=America/Los_Angeles
      - WEBTHEME=lcars
      - REV_SERVER=true
      - REV_SERVER_TARGET=192.168.2.1
      - REV_SERVER_DOMAIN=localdomain
      - REV_SERVER_CIDR=192.168.2.0/24
      - DNSSEC="true"
    volumes:
      - './etc/pihole:/etc/pihole:rw'
      - './etc/dnsmask:/etc/dnsmasq.d:rw'
      - './etc/cron:/etc/cron.d:rw'
      - './etc/updatelists:/etc/pihole-updatelists:rw'
    restart: unless-stopped
jacklul commented 2 years ago

You're mounting a volume for /etc/cron.d/, this is where the issue is - it does not merge the mount with existing files in the image - it overrides them. If you want to keep the mount you will have to copy contents of that directory (/etc/cron.d/ in the image) from the image into your mount directory (/etc/cron) - but I'm not 100% sure if this is gonna work at all.

mwatz1234 commented 2 years ago

That was it, able to use the merged docker file as well (pihole, doh, dot, and updatelists) as well. Thanks again for all the help.