Is Pi-Hole + NextCloudPi possible on one device?

I’m a complete novice here…

I have Pi-Hole running on a Raspberry Pi (Debian stretch), and would like to run a NextCloud server on the same device. Is this possible? If so, can someone provide pointers where I can download the appropriate app and get it onto the device?

Hello @bkfc,

I don’t have experience with NextCloud, but there is one project using it here https://matthias-kainer.de/blog/posts/raspberrypi-pictureframe-balena-docker-nextcloud/

You could check both docker-composer and try to merge them.

Let me know if you need further assistance :slight_smile:

I’ve looked at that page. It has pieces of relevant information, but, being a novice, I can’t connect the dots.

  1. There is a GitHub site here for NextCloudPi: https://github.com/nextcloud/nextcloudpi; do I simply run git to retrieve it?
  2. I see examples of docker-compose.yml, but don’t know how to script them. How do I script such a file?
  3. Where does this file go?
  4. If I run balena push on the NextCloudPi app, does that erase Pi-Hole?

At this point I’m going around in circles. It would be nice if there’s a site that has a fully documented example of running two containers.

@bkfc You can check the documentation on multi-container here https://www.balena.io/docs/learn/develop/multicontainer/

Download both files in the same folder and merge the docker-compose.yml file.
Keep me posted on the progress! :muscle:

There are really two separate workflows you can run here:

  • Run pihole (a software) on top of the OS which that NextCloudPi repo builds

  • Run pihole on BalenaOS.

It may help to take a look at our documentation articles like “What is Balena” [1] and possibly the docs for “BalenaOS” [2], the open-source operating system which is one of the fundamental building blocks of the ecosystem.

The key point is that to deploy and develop with Balena, you won’t need to install or work with any other pi operating systems like that provided by nextcloudpi.

Developing on Balena is its own workflow compared to developing with nextcloudpi or raspbian, etc. If you go through a “getting started” tutorial you may see what makes our ecosystem so interesting. For example we have a guide on our blog for setting up PiHole on Balena [3].

[1] https://www.balena.io/what-is-balena/
[2] https://www.balena.io/os/
[3] https://www.balena.io/blog/deploy-network-wide-ad-blocking-with-pi-hole-and-a-raspberry-pi/

For dt-rush: I’m not trying to develop anything, just looking to install a cloud-based system that will run locally on ARM-based machines (Raspberry Pi and Odroid), for which my preferred app (Synology Cloud Station) is not available. I’ve gone through the getting started materials, and used those to set up a Pi-Hole image. I was under the impression that I could run two services on the same machine, but this may require being an expert.

I tried merging the Pi-Hole and NextCloud folders, looks like I have to build a Docker version of NextCloud, but get hung up here:

bash-3.2$ ./build-docker.sh armhf

failed to dial gRPC: cannot connect to the Docker daemon. Is ‘docker daemon’ running on this host?: dial unix /var/run/docker.sock: connect: connection refused

Not being an expert, I don’t know why a daemon is not running on my Mac (not the eventual target machine, maybe that’s the problem), though docker is installed.

Got the docker daemon running on the Mac, which spent over an hour building the package. When I tried to push, I got this:

bash-3.2$ balena push AdBlockNextCloudCombo
[Error] Could not parse compose file
[Error] Bind mounts are not allowed
[Error] Not deploying release.
Remote build failed

Here is my attempt at merging the two docker-compose.yml files:

volumes:
  pihole_config:
  dnsmasq_config:
  ncdata:

services:
  nextcloudpi:
    image: ownyourbits/nextcloudpi-armhf
    command: "${IP}"
    ports:
     - "80:80"
     - "443:443"
     - "4443:4443"
    volumes:
     - ncdata:/data
     - /etc/localtime:/etc/localtime:ro
    container_name: nextcloudpi

  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: https://github.com/jedisct1/dnscrypt-proxy
  # 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:
    build: ./dnscrypt-proxy
    ports:
      - '5300:53/tcp'
      - '5300:53/udp'
    dns:
      - '127.0.0.1'
      - '1.1.1.1'

Addendum: I tried re-issuing the exact same push command, and got a different set of errors:

[…]
[Success] Successfully uploaded images
[debug] handling message: {“message”:"\u001b[31m[Error]\u001b[39m Some services failed to build:",“isError”:true}
[Error] Some services failed to build:
[debug] handling message: {“message”:"\u001b[31m[Error]\u001b[39m Service: main",“isError”:true}
[Error] Service: main
[debug] handling message: {“message”:"\u001b[31m[Error]\u001b[39m Error: lstat bin/: no such file or directory",“isError”:true}
[Error] Error: lstat bin/: no such file or directory
[debug] handling message: {“message”:"\u001b[31m[Error]\u001b[39m Not deploying release.",“isError”:true}
[Error] Not deploying release.
RemoteBuildFailedError: Remote build failed
at Bluebird.then (/usr/local/lib/balena-cli/build/utils/remote-build.js:53:19)
at tryCatcher (/usr/local/lib/balena-cli/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/balena-cli/node_modules/bluebird/js/release/promise.js:517:31)
at Promise._settlePromise (/usr/local/lib/balena-cli/node_modules/bluebird/js/release/promise.js:574:18)
at Promise._settlePromise0 (/usr/local/lib/balena-cli/node_modules/bluebird/js/release/promise.js:619:10)
at Promise._settlePromises (/usr/local/lib/balena-cli/node_modules/bluebird/js/release/promise.js:699:18)
at _drainQueueStep (/usr/local/lib/balena-cli/node_modules/bluebird/js/release/async.js:138:12)
at _drainQueue (/usr/local/lib/balena-cli/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/usr/local/lib/balena-cli/node_modules/bluebird/js/release/async.js:147:5)
at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/balena-cli/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
at process.topLevelDomainCallback (domain.js:126:23)


This is well beyond anything I could try to trace.

@BKFC you’re very close. Your first error message says Bind mounts are not allowed. The line /etc/localtime:/etc/localtime:ro in your docker-compose file is a bind mount so you’ll need to remove that.

I’m not sure what the second set of error messages are, but the first post looks sane. @dt-rush just meant that you’re “developing” an application to run on balena - your app will be the combination of Pi-hole and NextCloud :slight_smile: Running two apps within one is quite simple if they’re already set up for Docker, it sounds like you’ve had to do some extra work but that you’re almost there!

Thanks for the input. I simply deleted the offending lines in the docker-compose file. Since I’m flying blind, I have no idea how this will affect performance.

The balena push command ran to completion where I got the unicorn image. Now I have what’s hopefully a simpler problem: how to unattached the stand-alone pi-hole application running on my Raspberry Pi, and attach the combo package of pi-hole plus next cloud…

@bkfc
you should not need to do anything special to have the combo running on your device instead of a single service

balena push command will create a new release in your application and device will be updated to run the combo.

Again, my naiveté here: If I look at the Applications web page of the balena dashboard, I see my original pi-hole application with “1 Device” and AdBlockNextCloudCombo (target of the push command) with zero devices. If I click on the AdBlocker (original application), I see the device I’ve used all along with nothing new.

Should I have pushed to the original application that’s already assigned to the device? Is there a way to rename the application so that it reflects more activities?

None of this is obvious to me. Sorry.

@bkfc pushing to the existing application (like balena push AdBlockNextCloudCombo) would be easier to me.
You can still do it.
You can also transfer your device from one application to another wither with command line (leave/join commands) or with the dashboard UI (navigate to device -> actions -> click on “Move to another application”)

Got it - thanks. Now to see if the app works!

Some followup: both Docker apps (pi-hole and nextcloud server) appear to be running, that is, they give no error messages, but there appear to be problems with both:

  1. The pi-hole app is not logging any net traffic, even though everthing in my house is supposed to pass through it as a DNS. Also, I can’t log into the pi-hole admin console: every attempt lands me at the nextcloud server site.
  2. Netcloud is supposed to be a server that synchronizes files among clients in the same way as Dropbox. What I’m finding is that even the server web site mimics whatever files there are at the client, which means it does not sync at all. I am worried that deleting the lines with bind mounts now means that the server does not have a central folder structure that it uses to sync. I know little about bind mounts, but is there a correct way to do this? Otherwise it looks the server is just imitating each client and not synchronizing from a common file hierarchy.

Maybe both of these can be fixed via the docker-compose file, but I don’t know how to do that.

I’ve now migrated the device back to a container with the original pi-hole app. It is clearly working (accumulating and allowing/blocking web queries). So I’m doing without the second app for now.

I’m concluding that ‘merging’ two docker-compose files is highly non-trivial, leading to neither app running properly and possibly interfering with each other.