Can't find frontend after using network_mode = host with docker-compose

Hi everyone,

I recently moved my Home Assistant to docker, specifically docker-compose.
In the beginning I didn’t specify my network_mode in the docker-compose file, but just exposed port 8123.
There was no problem in accessing the Home Assistant frontend on my local-ip:8123.

I wanted to add my cast devices, but Google Cast didn’t show up in the integrations as it could not be discovered. After reading a few topics here, I discovered this had to do with the network_mode. This needed to be ‘host’ so auto-discovery could work.

Now I cant reach my frontend anymore… What do I need to do ? I can reach my mariaDB, and my node-red workflow.

My docker-compose file:

version: '3'

services:
  # HomeAssistant
  homeassistant:
    image: homeassistant/home-assistant:stable
    volumes:
      - homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    network_mode: host
    privileged: true
    depends_on:
      - mariadb
    # user: ${LOCAL_USER}:${LOCAL_USER}
    # devices:
    #   - "/dev/ttyACM0:/dev/ttyACM0"

  # MariaDB
  mariadb:
    image: mariadb/server:10.4
    volumes:
      - mariadb:/var/lib/mysql
    ports:
      - 3306:3306
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=ha_db
      - MYSQL_USER=homeassistant
      - MYSQL_PASSWORD=${HA_MYSQL_PASSWORD}
    restart: unless-stopped

  # NodeRed
  nodered:
    image: nodered/node-red:1.2.1
    volumes:
      - nodered:/data
    ports:
      - 1880:1880
    restart: unless-stopped
    depends_on:
      - homeassistant
    # user: '${LOCAL_USER}:${LOCAL_USER}'
    environment:
      - TZ=Europe/Brussels

volumes:
  homeassistant:
  nodered:
  mariadb:

I found this link to the official docs of docker, saying that network_mode only works on Linux hosts. I have a windows desktop with docker/docker-compose installed with WSL 2 (ubuntu 20). Am I running a linux host or is the windows my host ?

TIA,
Greetz Bert

You’re running on Windows

Thanks. Should I deinstall docker and install it in wsl2 of should I just install Linux as host is ? I would want to go to Linux as host os, but blueIris only runs on windows … That’s holding me from pulling the trigger to install Linux … If you say I should be good with docker in wsl2, than I would prefer going for that option.

The ADR for this install method says that only Linux installs are supported. A quick Google suggests that Docker on WSL2 is really Docker on Windows, but :man_shrugging:

Try it, see if host networking works. If it does, great, but if it doesn’t then you’re going to need to either run Linux in a VM, or Windows in a VM.

Or install a debian vm.

I’m having exactly the same issue, except I am running docker on Ubuntu on an Intel NUC. When using network_mode: host, the frontend is not responding on port 8123.
Is there a general config to be done in the Docker Engine of Docker compose? Not in the container?

I just installed HA using docker on raspbian. The docker compose file in the installation guide does not work if you want to access Home Assistant via the network from a browser. Bellow docker compose config makes it possible.

 homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - /opt/homeassistant/config:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    privileged: true
    ports:
      - "8123:8123"

Yes, it does. Doing what you did breaks many integrations that use mDNS/UPnP/discovery.

You should troubleshoot your broken Docker/host install.