How to run avahi in docker on a Linux host?

Viewed 896

I am trying to setup avahi in a docker container running on a Linux host. The purpose is to let avahi announce a service of my own and form me find the host and IP of the docker host.

So far avahi seems to run nicely in the container but I can not find my services searching from outside of my host.

I have googled alot and there are suggestions what to do but they all seems to be contradictory and/or insecure.

This is what I got so far.

docker-compose.yml

version: "3.7"
services:
    avahi:
        container_name: avahi
        build:
            context: ./config/avahi
            dockerfile: DockerFile
            network: host

DockerFile:

FROM alpine:3.13

RUN apk add --no-cache avahi avahi-tools
ADD avahi-daemon.conf /etc/avahi/avahi-daemon.conf
ADD psmb.service /etc/avahi/services/mpsu.service


ENTRYPOINT avahi-daemon --no-drop-root --no-rlimits

avahi-daemon.conf:

[server]
enable-dbus=no

psmb.service: (my service)

<!DOCTYPE service-group SYSTEM "avahi-service.dtd"> 
<service-group> 
    <name replace-wildcards="yes">PSMB</name>
    <service> <type>_mqtt._tcp</type> <port>1883</port>
        <txt-record>info=MPS Service Host</txt-record>
    </service>
</service-group>

This is from the terminal when starting avahi:

> docker-compose up                                       
Starting avahi ... done
Attaching to avahi
avahi    | avahi-daemon 0.8 starting up.
avahi    | WARNING: No NSS support for mDNS detected, consider installing nss-mdns!
avahi    | Loading service file /etc/avahi/services/mpsu.service.
avahi    | Loading service file /etc/avahi/services/sftp-ssh.service.
avahi    | Loading service file /etc/avahi/services/ssh.service.
avahi    | Joining mDNS multicast group on interface eth0.IPv4 with address 172.18.0.2.
avahi    | New relevant interface eth0.IPv4 for mDNS.
avahi    | Joining mDNS multicast group on interface lo.IPv4 with address 127.0.0.1.
avahi    | New relevant interface lo.IPv4 for mDNS.
avahi    | Network interface enumeration completed.
avahi    | Registering new address record for 172.18.0.2 on eth0.IPv4.
avahi    | Registering new address record for 127.0.0.1 on lo.IPv4.
avahi    | Server startup complete. Host name is 8f220b5ac449.local. Local service cookie is 1841391818.
avahi    | Service "8f220b5ac449" (/etc/avahi/services/ssh.service) successfully established.
avahi    | Service "8f220b5ac449" (/etc/avahi/services/sftp-ssh.service) successfully established.
avahi    | Service "PSMB" (/etc/avahi/services/mpsu.service) successfully established.

So,, how do I configure to be able to search for my service?
I would like to get the host information for the Host running docker.

0 Answers
Related