Homebridge in multi-container

Trying to get Homebridge working in a multi-container setup.

docker-compose.yml:

version: '2'
volumes:
  homebridge:
services:
  homebridge:
    build: ./homebridge
    privileged: true
    restart: always
    network_mode: host
    volumes:
      - 'homebridge:/'
    environment:
      - PGID=1000
      - PUID=1000      
  mqtt:
    image: panuwitp/mosquitto-arm
    ports:
      - '1883:1883'
  pibell:
    build: ./pibell
    depends_on:
      - mqtt
    privileged: true
    restart: always

And the homebridge Dockerfiles.template is:

FROM balenalib/%%BALENA_MACHINE_NAME%%-node

# use apt-get if you need to install dependencies,
# for instance if you need ALSA sound utils, just uncomment the lines below.
RUN apt-get update && apt-get install -yq \
    git make python g++ nodejs avahi-daemon avahi-discover libnss-mdns \
    libavahi-compat-libdnssd-dev && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

RUN /etc/init.d/dbus start
RUN /etc/init.d/avahi-daemon start

# Install homebridge
RUN npm install -g --unsafe-perm homebridge
RUN npm install -g --unsafe-perm homebridge-mqtt-switch-tasmota

# Copy config over
WORKDIR /root/.homebridge/

# Copy
COPY start.sh start.sh
COPY config.json config.json

# Execute permissions
RUN chmod +x start.sh

# Enable systemd init system in container
ENV INITSYSTEM on

# Expose port
EXPOSE 5353 51826

# Exec homebridge with persistent config
CMD /bin/bash /root/.homebridge/start.sh

All the files are here: https://github.com/chrisrichards/pibell-sub

When deployed on my RasperryPi 3, the mqtt and pibell containers start fine, but Homebridge is stuck in a loop ‘Installing service’. Any ideas how to get homebridge working?

Usually the intallaling loop means that our supervisor cannot bring the container up, because of some error in the start sequence i.e. start.sh in this case. I would suggest trying to only start homebridge on a bash shell (i.e. CMD bash) and then sshing in to run the rest of the start.sh and see where it breaks.