Multicast not working even with net=host

Hi All,

I’m trying to host a project on a computer that lives on my local network and have it discoverable via mDNS.
Ideally I have everything in a docker-compose.yml however I can’t get basic multicasting working when the app is containerised and using network_mode: "host"

The application is located here: mdns/examples at master · spider-gazelle/mdns · GitHub
If the application is run directly on the host via crystal ./examples/query_responder.cr then everything works as expected.

However if I run the application via docker, i.e. this example docker-compose
(link to the dockerfile for the image specified)

version: "3.7"

services:
  mdns:
    image: placeos/mdns-service:latest
    restart: always
    container_name: drivers-mdns
    network_mode: "host"
    environment:
      DOMAIN_NAMES: myservice.local
      IP_ADDRESS: "127.0.0.1"

then running ping myservice.local fails only when running the app in the container.
Given I’ve specified network_mode: host I would expect no difference in behaviour… Anyone have any ideas?

I think I found the issue: routes - Reroute mDNS query from WSL subnet to windows host subnet - Stack Overflow

Seems to be the fact that Docker Desktop runs in a VM so the --net=host flag doesn’t actually connect to the host network…

Things work fine when running on a Linux host

The observations are correct.

I am surprised the forum search didn’t yield any useful results for this topic, as multicast and host network with docker desktop have already been discussed a couple of times.

1 Like

I’m observing the same on OSX - and accept why it’s happening, but is there any workaround for eg MDNS to get through to the host?

I haven’t found a solution for it :frowning:

I researched further, and there seems to be some traction around using the Apple Virtualization Layer for this purpose Support Host Network (--network host) mode on Docker Desktop for Mac and Windows · Issue #238 · docker/roadmap · GitHub I haven’t gotten around to verifying that it works yet, though.