OpenDNS updater for Raspberry Pi 3

Hi, I have already installed pihole and dnscrypt proxy in Rasp Pi 3B+, and its running fantastically. (Instructions: https://www.balena.io/blog/deploy-network-wide-ad-blocking-with-pi-hole-and-a-raspberry-pi/ ).
I also want to add a ddclient service to the same device/application to update my OpenDNS host. I tried to ‘balena push’ the rpi-ddclient by Alan Kay (github: https://github.com/AjkayAlan/rpi-ddclient) but it erases the above pihole & dnscrypt-proxy service. But it works fine too.
How can I have all three services on the same application? Is there a better alternative for a DDNS udpdate client?

@jeevasaeyan Hey!

Thanks for giving the PiHole project a go. Looking at the 2 projects you should be able to include the rpi-ddclient service in the docker-compoe.yml of the PiHole source. Take a look here (https://github.com/klutchell/balena-pihole/blob/f3420be01307c42c92b7b4d930c25045fdc6e652/docker-compose.yml#L8) to see how the main PiHole service is defined and built. You should be able to duplicate this service, make the relevant changes to the build path resulting in an extra service in your application.

I hope this helps.

the ddclient failed to install with the following error:
Failed to install service ‘rpi-ddclient sha256:0018ef0b29b50af8aecec75d7dc0710b3e98272ac8a6d9915569575ec4f4ac04’ due to '(HTTP code 500) server error - readdirent: not a directory ’
rpi-ddlient-error

My docker-compose.yml:

volumes:
pihole_config:
dnsmasq_config:
ddclient_config:

services:
pihole:
build: ./pihole
privileged: true
volumes:
- ‘pihole_config:/etc/pihole’
- ‘dnsmasq_config:/etc/dnsmasq.d’
cap_add:
- ‘NET_ADMIN’
dns:
- ‘127.0.0.1’
- ‘1.1.1.1’
network_mode: host

optional upstream resolver: GitHub - DNSCrypt/dnscrypt-proxy: dnscrypt-proxy 2 - A flexible DNS proxy, with support for encrypted DNS protocols.

set pihole DNS1 and DNS2 service variables to 127.0.0.1:5300 to use this for upstream DNS

otherwise comment out this block to completely remove the service

dnscrypt-proxy:
image: klutchell/dnscrypt-proxy:2.0.19-arm
ports:
- ‘5300:53/tcp’
- ‘5300:53/udp’
dns:
- ‘127.0.0.1’
- ‘1.1.1.1’
rpi-ddclient:
build: ./pihole
privileged: true
volumes:
- ‘ddclient_config:/etc/ddclient.conf’
network_mode: host
environment:
- PUID=1000
- PGID=1000
restart: always

Dockerfile inside ./pihole:
FROM balenalib/raspberrypi3-debian:latest-build AS build

WORKDIR /usr/src

RUN install_packages cmake libraspberrypi-dev

RUN curl -sSL https://raw.githubusercontent.com/tasanakorn/rpi-fbcp/master/CMakeLists.txt -O
RUN curl -sSL https://raw.githubusercontent.com/tasanakorn/rpi-fbcp/master/main.c -O

WORKDIR /usr/src/build

RUN cmake .. && make

FROM pihole/pihole:4.2.2-1_armhf

WORKDIR /usr/src

COPY --from=build /opt/vc/lib/* /opt/vc/lib/
COPY --from=build /usr/src/build/fbcp /usr/src/
COPY services/ /etc/services.d/
COPY init/ /etc/cont-init.d/

RUN sed -i '/$AUTHORIZED_HOSTNAMES = array(/ a "balena-devices.com",' /var/www/html/admin/scripts/pi-hole/php/auth.php

# https://serverfault.com/a/817791
# force dnsmasq to really bind only the interfaces it is listening on
# otherwise dnsmasq will fail to start since balena is using 53 on some interfaces
RUN echo "bind-interfaces" >> /etc/dnsmasq.conf

RUN curl -fsSL https://raw.githubusercontent.com/jpmck/PADD/master/padd.sh -O \
	&& chmod +x padd.sh

# use wally3k's ticked list from https://firebog.net/
RUN curl -sSL https://v.firebog.net/hosts/lists.php?type=tick -o /etc/pihole/adlists.list

FROM resin/rpi-raspbian:stretch
LABEL maintainer="github.com/AjkayAlan"

USER root

# Install ddclient
RUN apt-get update \
    && apt-get install -y ddclient libio-socket-ssl-perl \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

COPY ddclient.conf /etc/ddclient.conf

# Use ddclient
CMD ["/usr/sbin/ddclient","-foreground"]

I’m actually a newbie, so some detailed fix will go a long way please!!

Hi ! Looking at your config - you’re almost there :slight_smile:

docker-compose takes multiple Docker-based applications and allows them to be deployed together as a single stack. It needs to know either about the image to pull for a specific app (you did this with dns proxy in the example above) or about a Dockerfile that tells it how to build an image - this is what the build keyword tells it about. I think both of your service definitions are pointing to pihole directory - try creating a new directory, with contents of the rpi-ddclient repo and then change the rpi-ddclient service build section to point to that directory. This would tell docker compose to build a new application image from the contents of that directory. It will find a Dockerfile there that would tell it how to build it and then Dockerfile can pull in more files if it needs to :slight_smile: hope this helps and let us know how it went :slight_smile: