Multi network container / ssdp/mdns traffic from host network - dns issue

I have two container that needs to communicate with each other.
One of the containers needs to be on the host network to send&receive udp multicast packages.

How can i do this with docker compose?

I got it working when i deploy the container per hand and use the container IPs.
But thats not suitable and feels like there must be a better way.

I want that the container that has its network type set to “host”, but its still possible to resolve other docker container names like they are on the same bridge network.

version: "2"
services:

  database:
    image: mongo
    container_name: database
    hostname: database
    ports:
      - "27017:27017"

  backend:
    image: "project/backend:latest"
    container_name: backend
    hostname: backend
    environment:
      - NODE_ENV=production
      - DATABASE_HOST=database
    ports:
      - "8080:8080"
    depends_on:
      - database
    tty: true

  connector:
    image: "project/connector:latest"
    container_name: connector
    hostname: connector
    environment:
      - NODE_ENV=production
      - BACKEND_HOST=backend
    depends_on:
      - backend
    #    net: host
    network_mode: "host"
    tty: true

The problem with the yaml file above is, that the connector can not resolve “backend”.

When a container uses the host network, it means you don’t have network isolation and you don’ use any of the Docker networks. It also means the DNS configuration, and host name resolution comes from the host. You can connect to the forwarded port of the backend on localhost. If that port is not 8080 (which is already forwarded) or you need to forward another. if you don’t want that port to be accessible remotely, just forward the port only from the loopback IP address:

    ports:
      - "127.0.0.1:8081:8081"

I used 8081 as an example. Use the port that you need.