Cannot access Web UI - Docker-Compose

Hey,
I want to install HA via docker-compose (already have some other containers running) on a Debian machine.
So I followed the official guide, took a video as help (Installing Docker and Home Assistant Container - YouTube) and so my docker-compose.yaml file looks like this:

  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
    network_mode: host

In Portainer I can see that it’s running, but I can’t assess the localhost:8123
This is how it looks in Portainer, and I’m curious because it’s the only container without IP/Ports but I don’t know what to do.


I already tried to add ports: - 8123:8123 to the .yaml, similar to my other containers, but then errors appeared while composing.

Its running in host networking mode so will inherit the IP address of the host it is running on, and won’t show anything under IP or ports in Portainer. You won’t specify ports with host networking mode or it creates errors like what you saw.

Your compose is a little different from mine - I use an environment variable for the timezone and don’t mount the /etc/localtime as a volume. Here’s the compose I use- I don’t use :stable and spell out the version number to pull, but you can do either :stable or :2022.6. I know Home Assistant documentation recommends GHCR but I still just use the docker hub path. I also just add the below compose as a “stack” in portainer per these instructions

version: '3.3'
services:
    home-assistant:
        container_name: homeassistant
        volumes:
            - '/home/mwav3/homeassistant:/config'
        environment:
            - TZ=America/New_York
        restart: always
        network_mode: host
        image: 'homeassistant/home-assistant:2022.6'

If that still doesn’t work, check the logs in the container to see if Home Assistant is even coming up and loading. Try http://192.168.0.yourip:8123 to access the Home Assistant instance as well, although localhost:8123 should work if you’re using the browser on the same host it is installed on.

Privileged mode is also not necessary if you are not mapping USB sticks to the Home Assistant instance.

I think I kind of fixed it myself, but thanks for your hint that HA should be reachable without “:8123” behind the IP.
It occurred to me that Pihole is running on that native IP (back then I followed this tutorial GitHub - geerlingguy/internet-pi: Raspberry Pi config for all things Internet.) and by comparing with other containers, I understood that I had to delete the network_mode: host line and added ports: - 8123:8123. Now everything functions fine.
Thanks for all your tips, e.g. updating via the web UI isn’t possible with docker.

1 Like

Some run it this way with the ports option specified for 8123, but there is a reason the documentation advises to use host networking mode. Many integrations rely on SSDP, a form of UPNP for discovery. This discovery will only work if you are using host networking mode. See the integrations that use it - none of these integrations will work properly without host networking mode. If you aren’t or don’t plan to use any of them, then you shouldn’t have a problem. If you do want to use them, you’ll need to use host networking mode and further trouble shoot why it isn’t working with your setup. Mine runs fine in host networking mode - You might be onto something about PiHole creating a conflict.

This will further explain different type of docker networking configurations

2 Likes

TIP for another OS users:

  • The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.

Networking using the host network | Docker Documentation

4 Likes

Hi everyone.
I have the same issue as the original poster and cannot access the WebUI.
I am running under Ubuntu Server with docker-compose and I can see portainer running and can access portainer UI on IP_ADDRESS:9000 (where IP_ADDRESS is the address for the server / Ubuntu machine). Logs for HA seem fine and loading but just cannot access it.
Removing network_host and instead using the ports works fine.
Any clues / ideas?

Docker-compose

version: '3.7'
services:
  homeassistant:
    container_name: homeassistant
    restart: always
    image: homeassistant/home-assistant:stable
    network_mode: host
    volumes:
      - ${USERDIR}/docker/homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
      - ${USERDIR}/docker/shared:/shared
    privileged: true
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
  
  portainer:
    container_name: portainer
    image: portainer/portainer-ce:latest
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    ports:
      - "9000:9000" 
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - $DOCKERDIR/portainer/data:/data
      - $DOCKERDIR/shared:/shared
    environment:
      - TZ=$TZ

HA logs

homeassistant    | s6-rc: info: service s6rc-oneshot-runner: starting
homeassistant    | s6-rc: info: service s6rc-oneshot-runner successfully started
homeassistant    | s6-rc: info: service fix-attrs: starting
homeassistant    | s6-rc: info: service fix-attrs successfully started
homeassistant    | s6-rc: info: service legacy-cont-init: starting
homeassistant    | s6-rc: info: service legacy-cont-init successfully started
homeassistant    | s6-rc: info: service legacy-services: starting
homeassistant    | services-up: info: copying legacy longrun home-assistant (no readiness notification)
homeassistant    | s6-rc: info: service legacy-services successfully started

Ok, noob error. Needed to open up the ports in the firewall on Ubuntu server which fixed the problem.

2 Likes

Hey, i’m getting exactly the same problem, but UFW is disabled. also seeing exactly the same logs as you shared… running with the same docker-compose on ubuntu

Are you accessing from the same machine or different one? From inside or outside the network?

Hi, I have actually the same issue… I’d like to use HA within a container (moving on from using HA via Vbox VM) on my Ubuntu 22.04. It’s the first time I am using dockers, so everything is new to me.

This is where I am stuck; No UI right after fresh HA install (docker compose)
=> hence onboarding in HA ++…

My 2x containers seem to run well: Portainer is all good (with the port redirection) // I can also access HA:8123 when “only” forwarding port 8123 in the yaml file (but i’d like to activate the network mode: host).

On Docker Desktop: I can connect in the CLI in the container, so i tested few things:

  • locally, the container sees the port 8123 (127.0.0.1:8123)
  • but is unable to see the port 8123 on the host (192.168.18.17:8123)
  • traceroute from Container to Host is working fine
  • Files in the container config/ folder are well created when launching HA the first time (with values in it, so i am assuming there is no access-right issue (i read that somewhere…))

My checks:

No firewall on the Ubuntu host

jm@jm-M:~/Docker$ sudo ufw status
Status: inactive

docker compose yaml file (i tried few version, fwiw)

jm@jm-M:~/Docker$ cat docker-compose.yaml 
version: '3.4'

services:
  portainer:
    container_name: portainer
    image: portainer/portainer-ce
    restart: always
    ports:
      - "9000:9000/tcp"
    environment:
      - TZ=Europe/London
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /home/jm/Docker/portainer:/data
#    network_mode: host

  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - /home/jm/Docker/homeassistant/config:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    privileged: true
    network_mode: host
#    ports:
#      - "8123:8123/tcp"

Others:

jm@jm-Mo:~/Docker$ pwd
/home/jm/Docker
jm@jm-M:~/Docker$ ls -alh
total 20K
drwxrwxr-x  4 jm jm 4.0K Sep 20 23:14 .
drwxr-x--- 22 jm jm 4.0K Sep 20 22:19 ..
-rw-rw-r--  1 jm jm  653 Sep 20 22:22 docker-compose.yaml
drwxrwxr-x  3 jm jm 4.0K Sep 20 23:03 homeassistant
drwxr-xr-x  7 jm jm 4.0K Sep 20 21:35 portainer

container logs:

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun home-assistant (no readiness notification)
s6-rc: info: service legacy-services successfully started
Unable to find configuration. Creating default one in /config
Unable to find configuration. Creating default one in /config
Unable to find configuration. Creating default one in /config
Unable to find configuration. Creating default one in /config
Unable to find configuration. Creating default one in /config

Checking the used ports on the host:

jm@jm-M:~/Docker$ sudo lsof -i -P -n | grep LISTEN
systemd-r  536 systemd-resolve   14u  IPv4  23210      0t0  TCP 127.0.0.53:53 (LISTEN)
sshd      1066            root    3u  IPv4  27714      0t0  TCP *:717 (LISTEN)
sshd      1066            root    4u  IPv6  27716      0t0  TCP *:717 (LISTEN)
smbd      1181            root   44u  IPv6  25499      0t0  TCP *:445 (LISTEN)
smbd      1181            root   45u  IPv6  25500      0t0  TCP *:139 (LISTEN)
smbd      1181            root   46u  IPv4  25501      0t0  TCP *:445 (LISTEN)
smbd      1181            root   47u  IPv4  25502      0t0  TCP *:139 (LISTEN)
x11vnc    1805              jm    8u  IPv4  31018      0t0  TCP *:5900 (LISTEN)
x11vnc    1805              jm    9u  IPv6  31019      0t0  TCP *:5900 (LISTEN)
com.docke 4045              jm   28u  IPv4  41446      0t0  TCP *:38743 (LISTEN)
com.docke 4045              jm  122u  IPv6  47550      0t0  TCP *:9000 (LISTEN)
vpnkit-br 4071              jm    9u  IPv4  41446      0t0  TCP *:38743 (LISTEN)
cupsd     7458            root    6u  IPv6  76791      0t0  TCP [::1]:631 (LISTEN)
cupsd     7458            root    7u  IPv4  76792      0t0  TCP 127.0.0.1:631 (LISTEN)

FYI:
also, the container can access to the port 9000 of the host (portainer).
the HA logs are empty (in config/ folder)
finally, (if that can make a difference): I am running (perfectly) Ubuntu 22.04 on a macbook

Any hints you see that may help?
(sorry for the long post)

1 Like

Hi all. I have installed HA on my Synology NAS, and configured following your instructions here.

I have also installed the Mosquito message broker as per a related Medium article

However after launching the container, and attempting to launch HA at the instructed URL http://192.168.1.10:8123

All I get is the Synology home page in the browser… no HA UI is rendered? Please help thanks

I’m having exactly the same problem on Raspberry Pi OS.

If I open a shell on the docker container I can access the webserver on port 8123. But from the host I cannot. The docker container ip responds to ping from the host. The “ufw” command shows firewall is off.

Any ideas?

I installed using the command:

docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=Europe/Zurich \
  -v /home/david/home_assistant_config:/config \
  --network=host \
  ghcr.io/home-assistant/home-assistant:stable

Edit: If I create an ubuntu docker container in host networking mode it has the same issue.

Seems by problem is identical to yours. Did you find a solution?

I’m using docker in Ubuntu so am not completely familiar with installing on raspberry os, but did you check the install directions for docker?

Others have had this issue when trying to install docker without removing old or prepackaged versions first. Running the command to remove old docker versions , even if you don’t think you have one, is always the first step when installing docker.

My problem went away if I ran the docker run command as root, using sudo!

You can follow these post install steps so you can manage docker as a non root user without needing to use sudo.

I have the same issue.

  • Ubuntu 22.04.2 LTS
  • Docker version 23.0.1, build a5ee5b1
  • Tried with and without root
  • ufw disabled
  • Tried dev images as well
  • Direct docker command as well docker compose

I’m using the same command as the page Linux - Home Assistant with many variations.

sudo docker run \                                                                                                        /data/+Config/HA  
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=America/Sao_Paulo \
  -v ./config:/config \
  --network=host \
  ghcr.io/home-assistant/home-assistant

They show those logs and then does nothing:

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun home-assistant (no readiness notification)
s6-rc: info: service legacy-services successfully started

I can’t access anything in the port 8123. Also, there is nothing listening on that port on the system, when I look with sudo ss -ltpn.

I followed exactly the official installation guide. Is there any bug or issue or am I missing something?

Is the config directory being created? If so, are there any logs in the config folder showing errors on why homeassistant won’t start? Also, are you running this in the directory you want to create the volume/config directory created? I like to spell out the whole path to define a volume to make sure it is putting it in exactly the right place on the host, no matter where I run the docker run command or compose from. For example, if your ubuntu user is “allan” and you create a folder called homeassistant to keep your config files, the volume would be defined like below:

-v /home/allan/homeassistant:/config

Other issues could be multiple versions of docker installed, or docker not installed properly (see link below for correct install directions for Ubuntu), and not following the post install steps I posted above to make sure you can manage docker as a non-root user. You should be able to run all docker commands without needing sudo. If docker isn’t a root user, it usually can’t manage all the ports in host networking mode and properly bind them from container to host.

sorry, very old thread but in case it helps others => issue was related to user rights on the files/folders.
adding the following in the docker-compose file solved it:

    environment:
      - PUID=1000
      - PGID=1000

eventually, resetting the folders ownership “may have” helped too:

sudo chown -R $USER ~/<your_top_docker_folder>/

Same issue. Running the container image with exactly the compose file posted in the docs, it starts, portainer shows that it is running and happy, no web UI.

I am running other services, but even disabling the network host option and giving it the 8123 port doesn’t solve it. Can you run this without giving it full access to the devices IP?