Can avahi publish services in other containers?

I want to run a music service, backup service and printing service in separate containers on my NAS box. I want to publish these services by running Avahi in it’s own container. Is there a way to get Avahi to see the other services in those other containers? What if I run Avahi on the host directly?

AFAIK, Avahi communicates via d-bus, and you can only run 1 Avahi per host. D-bus seems to be the fatal limitation. Any ideas how to get around this?

Thanks.

1 Like

Did you found a solution to this ? I’m interrested too…

Sorry, no. I never found an answer.

Setting up Avahi and multiple services in separate containers on your NAS box can indeed be a bit challenging due to the limitations of D-Bus and the single Avahi instance per host. However, there are a few potential workarounds you can consider:

  1. Host Networking Mode for Avahi Container: You could run Avahi in a container with the host’s network mode (--network host). This way, the Avahi instance inside the container would share the same network namespace as the host, and theoretically, it might be able to see and publish services from other containers on the same host. However, this approach might have security implications and can lead to conflicts.
  2. Reverse Proxy with Service Discovery: Instead of relying on Avahi for service discovery, you could set up a reverse proxy that forwards requests to the appropriate container based on the requested service. Then, you can use a service discovery mechanism (like Consul or etcd) to keep track of which service is running where. This approach adds a layer of abstraction between the services and the clients, allowing you to dynamically route requests based on the service type.
  3. Custom Service Discovery: You could implement your own service discovery mechanism using a central database or key-value store. Each service container could register itself with this mechanism upon startup, providing its IP and port. Avahi could then also register with this service and act as a proxy to route requests to the appropriate container based on the service type.
  4. Host-Level Avahi Configuration: Running Avahi directly on the host might be the simplest solution, especially if you’re dealing with a single NAS box. However, as you mentioned, this might lead to the limitation of a single Avahi instance per host.

In any case, overcoming the D-Bus limitation requires some creativity and might involve extra setup and maintenance. It’s important to carefully consider the security implications and ensure that your chosen approach aligns with your specific use case and security requirements.

1 Like