ESPHome Devices "Offline" but only for dashboard status

The marked solution works only for the HA appliance environment.
For those who run esphome dashboard in a separate docker environment (e.g. local PC), on the same network, using mDNS resolver:

  • use host networking
  • attach dbus and avahi daemon sockets
  • install avahi-utils in container

In details:

An example docker configuration:

    $ docker run -it --name esphome-db --network=host \
        -v "$PWD":/config \
        -e ESPHOME_DASHBOARD_USE_PING=true \
        -v /var/run/dbus:/var/run/dbus \
        -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket \
        esphome/esphome

    esphome-db$ apt -qq update && apt -y install avahi-utils # in container

Yes, installing avahi-utils manually in every container is inconvenient. You can use your own ‘forked’ images or whatever, but at least it works.