HomeAssistant + Docker Swarm + Homekit

The magic is twofold:

On each docker swarm node, run:

docker network create --config-only --subnet -o parent=eth0 --ip-range --gateway physical-config

Where: is the network that the docker host runs on

eth0 is the physical interface on the docker host that has access to the above network is a set of unused addresses on the network above. Note, this range MUST be different for each docker host you're using. Make sure this is outside your DHCP reservation range. is the gateway for the network described above.

This command must be run on ALL nodes in the swarm that you want the service to float to.

Second step:

Run the following on one of your docker swarm manager nodes.

docker network create -d macvlan --scope swarm --attachable --config-from physical-config physical

Third step:

Alter your compose file that contains your Home Assistant to look like this

version: '3.7'
    hostname: hass
    image: homeassistant/home-assistant:latest
      TZ: America/New_York
     - 8123:8123
     - 5353:5353 #homebridge
     - 21064:21064 #homebridge, default is 21063

     - /dockerVolumes/hass/:/config
     - default
     - physical
      driver: json-file

    driver: overlay
    attachable: true
    external: true

The additional network in the "networks" section allows your Home Assistant container to break out of the docker side networking and listen for mdns messages on your lan.

Bonus step:

If your docker hosts are on a different network than your IoT devices (a good practice), you will need an avahi reflector to bridge those networks. For me that is a simple LXC container that roams my cluster.