# Trying to combine projects on one Pi

**URL:** <https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962>\
**Category:** Project help\
**Created:** [August 19, 2022, 12:19pm UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962 "2022-08-19T12:19:41Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![MadScientist67](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@MadScientist67](https://forums.balena.io/u/MadScientist67)\
**Post date:** [August 19, 2022, 12:19pm UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/1 "2022-08-19T12:19:41Z")

</div>

Complete beginner here, trying to follow the instructions in [this article](https://www.balena.io/blog/two-projects-one-device-turn-your-raspberry-pi-into-a-multitool/#balenaSound-pihole) to combine the Balena Home Assistant and Balena PiHole projects on a RPi 4B, 4GB variant. I’ve worked through several releases and finally have all containers running but usually wind up either not being able to access the PiHole interface or the Home Assistant interface. In my current build, when I browse to the internal IP of my Pi, I get the PiHole admin interface. using when I try the IP as x.x.x.x:8213, I get a connection refused error. I can get to the configurator interface at x.x.x.x:3128 and I can reach the MQTT broker at x.x…x.x:1883.

I’m not sure where I’ve gone wrong here, and I’m not sure what the best way is to ask for help. Should I post the text of my docker-compose file?

---

<div class="post-metadata">

**Author:** ![rcooke-warwick](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@rcooke-warwick](https://forums.balena.io/u/rcooke-warwick)\
**Post date:** [August 19, 2022, 1:20pm UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/2 "2022-08-19T13:20:28Z")

</div>

Posting the docker compose file can never hurt - there’s likely a networking issue going on here and seeing the docker compose might help identify it quickly 🙂

---

<div class="post-metadata">

**Author:** ![MadScientist67](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@MadScientist67](https://forums.balena.io/u/MadScientist67)\
**Post date:** [August 19, 2022, 1:33pm UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/3 "2022-08-19T13:33:38Z")

</div>

OK, the forum won’t let me upload it, going to try to copy/paste it and see how this goes. The port 4199 is where I’m trying to enable the HomeAssistant container to listen on port 4199 for [this integration](https://github.com/garbled1/homeassistant_ecowitt)

```auto
version: '2'
volumes:
    config:
    mosquitto:
    pihole_config:
    dnsmasq_config:
services:
  pihole: 
    build: pihole
    ports: 
      - 8080:80 
    cap_add:
      - SYS_TTY_CONFIG
      - NET_ADMIN
    volumes:
      - "pihole_config:/etc/pihole"
      - "dnsmasq_config:/etc/dnsmasq.d"
    dns:
      - "127.0.0.1"
      - "1.1.1.1"
    network_mode: host
    labels:
      io.balena.features.dbus: "1"
    devices:
      - /dev/tty0
      - /dev/tty1

  unbound:
    build: unbound
    ports:
      - "5053:5053/tcp"
      - "5053:5053/udp"

  # https://github.com/balenablocks/fbcp
  fbcp:
    image: balenablocks/fbcp:1.0.0
    privileged: true

  # https://github.com/balenablocks/hostname
  hostname:
    build: hostname
    restart: no
    labels:
      io.balena.features.supervisor-api: 1
    environment:
      SET_HOSTNAME: HomeHole
  homeassistant:
    build: homeassistant
    ports:
      - 8123:80
      - 4199:4199
    privileged: true
    volumes:
      - 'config:/config'
    restart: always
  mqtt:
    build: mqtt
    ports:
      - "1883:1883"
    restart: always
    volumes:
      - mosquitto:/mosquitto/data
  hass-configurator:
    image: "causticlab/hass-configurator-docker:latest"
    restart: always
    ports:
      - "3218:3218"
    volumes:
      - 'config:/hass-config'
    environment:
      - HC_BASEPATH=/hass-config

```

---

<div class="post-metadata">

**Author:** ![rcooke-warwick](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@rcooke-warwick](https://forums.balena.io/u/rcooke-warwick)\
**Post date:** [August 19, 2022, 1:44pm UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/4 "2022-08-19T13:44:18Z")

</div>

Hey, nice one I can see the docker compose just fine.

```auto
homeassistant:
    build: homeassistant
    ports:
      - 8123:80

```

This is mapping the HOST port 8123 to port 80 of the homeassistant container - can you confirm that there is something listening on port 80 of that container?

---

<div class="post-metadata">

**Author:** ![MadScientist67](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@MadScientist67](https://forums.balena.io/u/MadScientist67)\
**Post date:** [August 19, 2022, 1:51pm UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/5 "2022-08-19T13:51:50Z")

</div>

![image](https://global.discourse-cdn.com/balena/original/2X/4/407c61ac467ed3b45cedd5929da567e358a43680.png)  
Seems like there isn’t. Should that be 8123:8123 instead? I may have messed up something when combining the two docker-compose files.

Here’s the section for home assistant from the original Balena-Home Assistant project:

```auto
services:
  homeassistant:
    build: homeassistant
    ports:
      - 80:8123
    privileged: true
    volumes:
      - 'config:/config'
    restart: always

```

---

<div class="post-metadata">

**Author:** ![rcooke-warwick](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@rcooke-warwick](https://forums.balena.io/u/rcooke-warwick)\
**Post date:** [August 19, 2022, 2:28pm UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/6 "2022-08-19T14:28:06Z")

</div>

hey there, you’re right - if that was in the original docker compose then its likley home assistant is listening on port 8123 of the container - so `8123:8123` should lead to it being exposed on :8123 like your other services

In the original home assistant project, port 80 of the host was being forwarded to port 8123 of the container - probably as that would make it available on just `<host IP>` or the balena cloud public url 🙂

---

<div class="post-metadata">

**Author:** ![MadScientist67](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@MadScientist67](https://forums.balena.io/u/MadScientist67)\
**Post date:** [August 19, 2022, 2:50pm UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/7 "2022-08-19T14:50:59Z")

</div>

That did it! set it to 8123:8123 and pushed a new release and now x.x.x.x goes straight to the PiHole and x.x.x.x:8123 takes me to HomeAssistant.

Thanks for all the help!

Edit:

---

<div class="post-metadata">

**Author:** ![MadScientist67](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@MadScientist67](https://forums.balena.io/u/MadScientist67)\
**Post date:** [August 19, 2022, 7:46pm UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/9 "2022-08-19T19:46:59Z")

</div>

OK, ran into a problem. While everything is working, I can’t access Home Assistant via the public URL and I think it’s because that only allows access to Port 80. I thought that I could just swap ports and point the PiHole instance to another port since I can manage it from within Home Assistant but now that I’ve done it, I can’t get HA to launch - the container just shows “installed” and it keeps trying to launch over and over. I guess that’s why the port was set up to be forwarded in the base version, so that it could be accessed from the URL.

```auto
version: '2'
volumes:
    config:
    mosquitto:
    pihole_config:
    dnsmasq_config:
services:
  pihole: 
    build: pihole
    ports: 
      - 8080:8080 
    cap_add:
      - SYS_TTY_CONFIG
      - NET_ADMIN
    volumes:
      - "pihole_config:/etc/pihole"
      - "dnsmasq_config:/etc/dnsmasq.d"
    dns:
      - "127.0.0.1"
      - "1.1.1.1"
    network_mode: host
    labels:
      io.balena.features.dbus: "1"
    devices:
      - /dev/tty0
      - /dev/tty1

  unbound:
    build: unbound
    ports:
      - "5053:5053/tcp"
      - "5053:5053/udp"

  # https://github.com/balenablocks/fbcp
  fbcp:
    image: balenablocks/fbcp:1.0.0
    privileged: true

  # https://github.com/balenablocks/hostname
  hostname:
    build: hostname
    restart: no
    labels:
      io.balena.features.supervisor-api: 1
    environment:
      SET_HOSTNAME: HomeHole
  homeassistant:
    build: homeassistant
    ports:
      - 80:8123
      - 4199:4199
    privileged: true
    volumes:
      - 'config:/config'
    restart: always
  mqtt:
    build: mqtt
    ports:
      - "1883:1883"
    restart: always
    volumes:
      - mosquitto:/mosquitto/data
  hass-configurator:
    image: "causticlab/hass-configurator-docker:latest"
    restart: always
    ports:
      - "3218:3218"
    volumes:
      - 'config:/hass-config'
    environment:
      - HC_BASEPATH=/hass-config

```

---

<div class="post-metadata">

**Author:** ![rcooke-warwick](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@rcooke-warwick](https://forums.balena.io/u/rcooke-warwick)\
**Post date:** [August 22, 2022, 8:13am UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/11 "2022-08-22T08:13:17Z")

</div>

Hi there, you’re right - the public url gives access to port 80, so if you want to access home assistant to it, you’ll have to map the host port 80, to the port being listened to by home-assistant, as you have done in your docker-compose.

Do you see any log messages in the terminal in the dashboard that indicate what the error might be?

---

<div class="post-metadata">

**Author:** ![rcooke-warwick](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@rcooke-warwick](https://forums.balena.io/u/rcooke-warwick)\
**Post date:** [August 22, 2022, 8:18am UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/12 "2022-08-22T08:18:18Z")

</div>

Is it possible that pihole is listening on port 80? It is in host mode networking, which means that if whatever is inside the pihole container listens on port 80 - then it is using host port 80. As you are forwarding host port 80 now to port 8123 for home assistant, I wonder if that leads to some sort of port conflict that’s causing the home assistant container to error and restart

---

<div class="post-metadata">

**Author:** ![rcooke-warwick](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@rcooke-warwick](https://forums.balena.io/u/rcooke-warwick)\
**Post date:** [August 22, 2022, 8:37am UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/13 "2022-08-22T08:37:30Z")

</div>

I think this might be it - looking at the docker image the pihole hub app is based on [GitHub - pi-hole/docker-pi-hole: Pi-hole in a docker container](https://github.com/pi-hole/docker-pi-hole) , pihole uses port 80 for its web interface by default - as its in host networking mode (I think this is required too), this means it will hog port 80 on your device. This will lead to a port conflict when mapping port 80 to anything else (homeassistant container in your case).

What to do about it - I’m not entirely sure

- maybe there’s a way to change pihole so it isn’t using port 80
- I think its the web interface that is using port 80 - maybe there’s a way to disable it to free up port 80?
- can pihole be used outside of `network_mode: host`? [Docker Hub](https://hub.docker.com/r/pihole/pihole) suggests it can be - but you won’t be able to use its DHCP

I’m not that familiar with pihole so can’t say for sure!

---

<div class="post-metadata">

**Author:** ![arcsi](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@arcsi](https://forums.balena.io/u/arcsi)\
**Post date:** [August 24, 2022, 4:01pm UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/15 "2022-08-24T16:01:41Z")

</div>

Hey,

I know it’s not much help, but I ran into the same issue a week ago and managed to force pihole to run it’s admin interface on a different port. The solution included an sed command that I put into the dockerfile of the PiHole, and the sed command I found somewhere online basically changed the port number in the config files when building the image.

I can look for the dockerfile and the place where I found this solution if needed.

---

<div class="post-metadata">

**Author:** ![TJvV](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@TJvV](https://forums.balena.io/u/TJvV)\
**Post date:** [August 25, 2022, 7:51am UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/16 "2022-08-25T07:51:56Z")

</div>

Hi,

I can think of a couple of solutions.  
One is to run a proxy ([pihole example](https://github.com/pi-hole/docker-pi-hole/blob/master/examples/docker-compose-nginx-proxy.yml), [generic example](https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/)), that redirects certain subdomains to certain containers.  
You could have `nginx` config entries like

```auto
server {
    listen 80;
    server_name ha.*;

    proxy_pass http://homeassistant:8123$request_uri;
}

server {
    listen 80;
    server_name *;

    proxy_pass http://pihole$request_uri;
}

```

That would make `nginx` listen on port 80 and forward `ha.<public URL>` to homeassistant and `<public URL>` to pihole.

Other (if you’re keen on using `network=host`) is to try your luck with the pi hole docker environment variable `WEB_PORT` as described in the [readme](https://github.com/pi-hole/docker-pi-hole/blob/master/README.md#advanced-variables)  
[In the sources](https://github.com/pi-hole/docker-pi-hole/blob/master/src/scripts/bash_functions.sh#L318) it looks like this changes the management port from `80` to whatever you filled in.

I have zero experience with pihole and homeassistant though, this is just from my experience with nginx reverse proxies in docker-compose 🙂

---

<div class="post-metadata">

**Author:** ![mpous](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mpous/32/4742_2.png) [@mpous](https://forums.balena.io/u/mpous)\
**Post date:** [August 26, 2022, 10:22am UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/17 "2022-08-26T10:22:19Z")

</div>

Great idea @TJvV i will try it myself!

@MadScientist67 BTW welcome to the balena community! I think balenaCloud Public URL also accepts the port `8080`, if i’m not wrong.

Now you have 2 possible solutions, let us know if that works for you 🙂

---

<div class="post-metadata">

**Author:** ![MadScientist67](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@MadScientist67](https://forums.balena.io/u/MadScientist67)\
**Post date:** [August 26, 2022, 12:11pm UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/19 "2022-08-26T12:11:17Z")

</div>

Thanks everyone, this wound up taking a backseat for a few days, but I’m hoping to get back to it this weekend. I’ll give this a shot and let y’all know

---

<div class="post-metadata">

**Author:** ![MadScientist67](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@MadScientist67](https://forums.balena.io/u/MadScientist67)\
**Post date:** [August 27, 2022, 1:37pm UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/20 "2022-08-27T13:37:32Z")

</div>

OK, got some time to play with things this morning.

Taking a little bit from everyone, I used the WEB\_PORT variable and set to 8080 and changed the port in the docker-compose file to 8080 as well and everything seems to be working OK.

Here’s the docker-compose in case this will help someone else in the future that stumbles across this thread.

```auto
version: '2'
volumes:
    config:
    mosquitto:
    pihole_config:
    dnsmasq_config:
services:
  pihole: 
    build: pihole
    ports: 
    - "80:8080"
    cap_add:
      - SYS_TTY_CONFIG
      - NET_ADMIN
    volumes:
      - "pihole_config:/etc/pihole"
      - "dnsmasq_config:/etc/dnsmasq.d"
    dns:
      - "127.0.0.1"
      - "1.1.1.1"
    network_mode: host
    labels:
      io.balena.features.dbus: "1"
    devices:
      - /dev/tty0
      - /dev/tty1

  unbound:
    build: unbound
    ports:
      - "5053:5053/tcp"
      - "5053:5053/udp"

  # https://github.com/balenablocks/hostname
  hostname:
    build: hostname
    restart: no
    labels:
      io.balena.features.supervisor-api: 1
    environment:
      SET_HOSTNAME: HomeHole
  homeassistant:
    build: homeassistant
    ports:
      - 80:8123
    privileged: true
    volumes:
      - 'config:/config'
    restart: always
  mqtt:
    build: mqtt
    ports:
      - "1883:1883"
    restart: always
    volumes:
      - mosquitto:/mosquitto/data
  hass-configurator:
    image: "causticlab/hass-configurator-docker:latest"
    restart: always
    ports:
      - "3218:3218"
    volumes:
      - 'config:/hass-config'
    environment:
      - HC_BASEPATH=/hass-config

```

---

<div class="post-metadata">

**Author:** ![mpous](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mpous/32/4742_2.png) [@mpous](https://forums.balena.io/u/mpous)\
**Post date:** [August 29, 2022, 10:39am UTC](https://forums.balena.io/t/trying-to-combine-projects-on-one-pi/360962/21 "2022-08-29T10:39:13Z")

</div>

Thank you @MadScientist67 for sharing your solution!
