Docker Community Forums

Share and learn in the Docker community.

Docker network host broadcast issue

I’m working on running a Unquiti Unifi Controller in an Ubuntu VM running docker and have used a the following docker-compose to build this container. I do currently have the the Unifi Controller working using their Ubuntu / Debian installer into a different base Ubuntu VM (not running docker).

The issue that I’m having is with the Layer 2 discovery protocol, that detects Unifi devices in the same network. The container runs and I can get to it but no devices get automatically discovered.

It looks like others may have gotten this to work.

version: "2.4"
services:
  Unifi:
    container_name: Unifi
    environment:
      - PGID=100
      - PUID=1025
      - TZ=Asia/Bangkok
    image: linuxserver/unifi-controller:latest
    restart: unless-stopped
    volumes:
      - unifi_config:/config
    network_mode: host
volumes:
    unifi_config:
        external: true

As of now (Docker 18.06+) UDP broadcasts work out of the box, as long as your are using the default bridge network and all containers run on the same host (and of course in the same docker network).

Using docker-compose services are automagically run in the same network and thus the following docker-compose.yml:

version: ‘3.4’

services:

master-cat:
image: alpine
command: nc -l -u -p 6666

slave-cat:
image: alpine/socat
depends_on:
- master-cat
entrypoint: ‘’
command: sh -c “echo ‘Meow’ | socat - UDP4-DATAGRAM:255.255.255.255:6666,so-broadcast”
with docker-compose up will show Meow on the master-cat (sic!).

If you want to use broadcasts across multiple hosts, this is not possible with the default network plugins that docker ships with. → UDP broadcast not working with multi-host networking · Issue #17814 · moby/moby · GitHub. But a more sophisticated overlay network plugin, such as Weave should work (I have not tested it…)