homebridge / docker-homebridge

Homebridge Docker. HomeKit support for the impatient using Docker on x86_64, Raspberry Pi (armhf) and ARM64. Includes ffmpeg + libfdk-aac.
https://hub.docker.com/r/homebridge/homebridge/
GNU General Public License v3.0
2.59k stars 243 forks source link

mDNS in a Docker container #552

Closed adilinden closed 7 months ago

adilinden commented 9 months ago

Current Situation

I am running homebridge in a docker container on Debian 11 (bullseye). Since my host already runs avahi-daemon I would like to have homebridge utilize it to advertise itself. I following the instructions in https://github.com/homebridge/homebridge/wiki/mDNS-Options but there's no sign of homebridge on my network. I explicitly enabled dbus support in the avahi-daemon configuration, although I suspect it may be enabled by default already. The hosts avahi-daemon.conf looks identical to the avahi-daemon.conf inside to homebridge container. It does not matter whether I run the homebridge container with host mode or not, neither works.

How can I tell if homebridge is properly using dbus? Sorry, but this is the first time I am touching dbus in any way.

Logs

With debug enabled (omitted all the individual modules logging)

[2/12/2024, 5:08:01 PM] [HB Supervisor] Homebridge Storage Path: /var/lib/homebridge
[2/12/2024, 5:08:01 PM] [HB Supervisor] Homebridge Config Path: /var/lib/homebridge/config.json
[2/12/2024, 5:08:01 PM] [HB Supervisor] Logging to /var/lib/homebridge/homebridge.log
[2/12/2024, 5:08:01 PM] [HB Supervisor] OS: Linux 5.10.0-28-amd64 x64
[2/12/2024, 5:08:01 PM] [HB Supervisor] Node.js v18.19.0 /opt/homebridge/bin/node
[2/12/2024, 5:08:01 PM] [HB Supervisor] Homebridge Path: /var/lib/homebridge/node_modules/homebridge/bin/h
omebridge
[2/12/2024, 5:08:01 PM] [HB Supervisor] UI Path: /opt/homebridge/lib/node_modules/homebridge-config-ui-x/d
ist/bin/standalone.js
[2/12/2024, 5:08:02 PM] [Homebridge UI] Homebridge UI v4.55.1 is listening on 0.0.0.0 port 8581

[2/12/2024, 5:08:02 PM] [HB Supervisor] Starting Homebridge with extra flags: -I -P /var/lib/homebridge/no
de_modules -D --strict-plugin-resolution
[2/12/2024, 5:08:02 PM] [HB Supervisor] Started Homebridge v1.7.0 with PID: 2879

Without debug

[2/12/2024, 5:11:02 PM] [HB Supervisor] Homebridge Storage Path: /var/lib/homebridge
[2/12/2024, 5:11:02 PM] [HB Supervisor] Homebridge Config Path: /var/lib/homebridge/config.json
[2/12/2024, 5:11:02 PM] [HB Supervisor] Logging to /var/lib/homebridge/homebridge.log
[2/12/2024, 5:11:02 PM] [HB Supervisor] OS: Linux 5.10.0-28-amd64 x64
[2/12/2024, 5:11:02 PM] [HB Supervisor] Node.js v18.19.0 /opt/homebridge/bin/node
[2/12/2024, 5:11:02 PM] [HB Supervisor] Homebridge Path: /var/lib/homebridge/node_modules/homebridge/bin/homebridge
[2/12/2024, 5:11:02 PM] [HB Supervisor] UI Path: /opt/homebridge/lib/node_modules/homebridge-config-ui-x/dist/bin/standalone.js
[2/12/2024, 5:11:03 PM] [Homebridge UI] Homebridge UI v4.55.1 is listening on 0.0.0.0 port 8581
[2/12/2024, 5:11:03 PM] [HB Supervisor] Starting Homebridge with extra flags: -I -P /var/lib/homebridge/node_modules --strict-plugin-resolution
[2/12/2024, 5:11:03 PM] [HB Supervisor] Started Homebridge v1.7.0 with PID: 5156
[2/12/2024, 5:11:03 PM] Loaded config.json with 8 accessories and 6 platforms.
[2/12/2024, 5:11:03 PM] Loaded 54 cached accessories from cachedAccessories.
[2/12/2024, 5:11:04 PM] ---
[2/12/2024, 5:11:04 PM] Loaded plugin: homebridge-camera-ffmpeg@3.1.4
[2/12/2024, 5:11:04 PM] Registering platform 'homebridge-camera-ffmpeg.Camera-ffmpeg'
[2/12/2024, 5:11:04 PM] ---
[2/12/2024, 5:11:04 PM] Loaded plugin: homebridge-mqttthing@1.1.47
[2/12/2024, 5:11:04 PM] Registering accessory 'homebridge-mqttthing.mqttthing'
[2/12/2024, 5:11:04 PM] ---
[2/12/2024, 5:11:04 PM] Loaded plugin: homebridge-shelly@0.19.1
[2/12/2024, 5:11:04 PM] Registering platform 'homebridge-shelly.Shelly'
[2/12/2024, 5:11:04 PM] ---
[2/12/2024, 5:11:04 PM] Loaded plugin: homebridge-simple-wled@1.4.1
[2/12/2024, 5:11:04 PM] Registering platform 'homebridge-simple-wled.WLED'
[2/12/2024, 5:11:04 PM] ---
[2/12/2024, 5:11:05 PM] Loaded plugin: homebridge-unifi-protect@6.16.0
[2/12/2024, 5:11:05 PM] Registering platform 'homebridge-unifi-protect.UniFi Protect'
[2/12/2024, 5:11:05 PM] ---
[2/12/2024, 5:11:05 PM] Loaded plugin: homebridge-z2m@1.9.3
[2/12/2024, 5:11:05 PM] Registering platform 'homebridge-z2m.zigbee2mqtt'
[2/12/2024, 5:11:05 PM] ---
[2/12/2024, 5:11:05 PM] Loading 6 platforms...

Configuration

From homebridge/config.json

    "bridge": {
        "name": "Homebridge 9AC4",
        "username": "0E:CC:4D:10:9A:C4",
        "port": 51856,
        "pin": "379-08-490",
        "advertiser": "avahi"
    },

From egrep -v '^\s*#' /etc/avahi/avahi-daemon.conf

[server]
use-ipv4=yes
use-ipv6=no
enable-dbus=yes
ratelimit-interval-usec=1000000
ratelimit-burst=1000

[wide-area]
enable-wide-area=yes

[publish]
publish-hinfo=no
publish-workstation=no

[reflector]

[rlimits]

From docker-compose.yml

  homebridge:
    image: homebridge/homebridge:latest
    container_name: homebridge
    environment:
      - TZ=${TZ:-America/Winnipeg}
      - ENABLE_AVAHI=0
    volumes:
      - ./volumes/homebridge:/homebridge
      - /var/run/dbus:/var/run/dbus
      - /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket
    security_opt:
      - apparmor:unconfined
    network_mode: host
      #ports:
      #- "8581:8581"
      #- "51856:51856"

Environment

Process Supervisor

Docker (Mention image name in Additional Context)

Additional Context

homebridge/homebridge:latest

NorthernMan54 commented 9 months ago

I’m not an expert on dbus, but am thinking this may not be feasible. As the avaihi daemon needs to be told about homebridge, and the container running homebridge would need to tell your host avahi daemon about it.

have you tried googling docker and shared dbus support?

PS I’m currently on vacation, and won’t have access to my test environment for a month

taw123 commented 8 months ago

FYI- Looks similar to my issue #558

I was/am able to bring HB up but NOT leverage the AVAHI for mDNS advertising as I too was unable to share the daemon.

You MUST use host mode (and make sure you aren't on separate VLANs unless you set up a VLAN rule/relay/broadcaster)

Alternatively you could do what I did 5 years ago when I was more actively using this, set up a Docker MACLAN... Silly to do and a waste of resources but might look into setting that up again. That way you have a distinct MAC address for HB and and of course can run another instance to the AVAHI daemon as it will be running on it's own IP address..

Again not the ideal solution but worth mentioning...

--T

github-actions[bot] commented 7 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 7 months ago

This issue has been closed as no further activity has occurred.