HomeAssistant running on Docker Desktop for Windows but not accessible from browser

Hello,

I’m a software developer but new to HomeAssistant. I have HomeAssistant running, or at least appears to be running, via a docker container but I cannot connect to it from my host machine, the WSL VM, or even exec’ed into the container that is running itself.

My setup:

OS Name:         Microsoft Windows 10 Home
OS Version:      10.0.19043 N/A Build 19043
Docker version 20.10.11, build dea9396

I started the container using this command:

docker run -d -p 8123:8123 --privileged \
  --volume "C:\Program Files\homeassistant:/config" \
  --name homeassistant \
  --network host \
  -e "TZ=America/New_York" ghcr.io/home-assistant/home-assistant:stable

The container stays running and has this in the logs:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.

Yet none of these load from my browser:

  • http://localhost:8123
  • http://127.0.0.1:8123
  • http://host.docker.internal:8123

And even when I hop into the WSL VM that I’ve configured docker to use (wsl -d Ubuntu), I just get:

$ curl localhost:8123
curl: (7) Failed to connect to localhost port 8123: Connection refused
$ curl http://127.0.0.1:8123
curl: (7) Failed to connect to 127.0.0.1 port 8123: Connection refused

And even when I exec into the container via docker exec -ti homeassistant /bin/bash:

# curl -v http://127.0.0.1:8123
*   Trying 127.0.0.1:8123...
* Connected to 127.0.0.1 (127.0.0.1) port 8123 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8123
> User-Agent: curl/7.78.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< location: /onboarding.html
< Content-Length: 0
< Content-Type: application/octet-stream
< Date: Fri, 24 Dec 2021 11:43:38 GMT
< Server: Python/3.9 aiohttp/3.8.1
<
* Connection #0 to host 127.0.0.1 left intact

Which I guess actually looks like it’s connecting to the server, but no data is being returned.

It’s doing a redirect, so use “curl -L” to follow through.
You’re likely have networking issues between Windows proper and WSL(2?).

@koying

It’s doing a redirect, so use “curl -L” to follow through.

Yes, you’re right, doing curl -L http://127.0.0.1:8123 while exec’ed into the docker container gives me an HTML page. So I know the server is running and serving the page, there seems to be some kind of a networking block.

You’re likely have networking issues between Windows proper and WSL(2?).

Yes, it’s WSL 2.

Maybe there are also networking issues between Windows proper and the WSL2 VM, but even ignoring windows, when I hop into the Ubuntu terminal I can see:

$ docker ps -a
CONTAINER ID   IMAGE                                          COMMAND   CREATED       STATUS       PORTS     NAMES
e2266fce648b   ghcr.io/home-assistant/home-assistant:stable   "/init"   3 hours ago   Up 3 hours             homeassistant

But no web page:

$ curl -L -v http://127.0.0.1:8123
*   Trying 127.0.0.1:8123...
* TCP_NODELAY set
* connect to 127.0.0.1 port 8123 failed: Connection refused
* Failed to connect to 127.0.0.1 port 8123: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 127.0.0.1 port 8123: Connection refused

Turns out it was the --network=host option:

From here:

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.

So removing that flag and using this command:

docker run -d -p 8123:8123 --privileged --volume "C:\Program Files\homeassistant:/config" --name homeassistant -e "TZ=America/New_York" ghcr.io/home-assistant/home-assistant:stable

And now I can access my home assistant :slight_smile:

7 Likes

This is interesting, I’m running kiosk with windows 10 installed and I’d love to achieve this.
Can you give step by step tutorial on how to do this?
Also would there be any issue passthru usb dongle like sonoff zigbee or even coral?
I’m currently trying debian + HA supervised but the constant poem writing from debugging error is just not for me :smiley:
And I plan to use skype which is more stable on windows than debian,

1 Like

I’ve never run home assistant on docker on windows, but I have worked quite a bit with docker on windows otherwise.

After you install Docker Desktop for Windows, the steps would be pretty much the same as the steps for using the docker container on linux, except when you do the “Install” and “Update” commands that use docker run -d --options and --stuff ... --network=host --other options just leave out the “–network=host” part, but leave the rest of the command alone.

Also would there be any issue passthru usb dongle like sonoff zigbee or even coral?

100%. Docker on Windows uses MS HyperV to run a linux virtual machine and then docker daemon is running on linux inside that VM. Additionally there’s a bunch of extra stuff that allows the docker commands you run from power shell or the windows command prompt to control docker that’s running on linux in the VM. Unfortunately, HyperV (unlike VirtualBox and VMWare) doesn’t support USB passthrough. So you’re just dead in the water here.

Before Docker Desktop was available for Windows, we used to use Boot2Docker which was a linux image you could run on VirtualBox and control from the Windows cmdline much like Docker Desktop, but that project hasn’t been touched since Feb 2020 and was officially deprecated in June 2020. It’s also a lot more work.

If you want HomeAssistant on Windows with USB devices, I would probably try HomeAssitant OS for x86-64 running on VirtualBox or VMWare Player.

Thanks for the answer, I have moved to debian + HA supervised since posting this.
Even with that sometimes there are issues with usb connection.
I’m gonna go with POE based zigbee, still waiting for the dongle to arrive,
looks like it’s the most stable compared to usb-based solution

Hi everybody,
this thread made home assistnat working in “Docker Desktop” for Windows working for me too,
but
the path “c:\program files …” does not work as it requires admin privileges to write there. Therefore changing the path to “c:\progs\docker\homeassistant” … made the whole thing working in my case:

docker run -d -p 8123:8123 --privileged --volume "C:\progs\Docker\homeassistant:/config" --name homeassistant3 -e "TZ=Europe/Vienna" ghcr.io/home-assistant/home-assistant:stable

thx 2 all knowledge shareres / contributors!

Real noob here, but I just managed to get the Linux Docker image working on Docker Desktop for Mac.
I tried to use various canned images for HA, but ran into trouble. The Virtual Box image would work, but that meant I would need to have another virtualization program running as I’d already had another container running TeslaMate. TeslaMate mentioned that it integrated with HA, so I was game to get it working on the same machine.
I can confirm that the run command is very similar to the one for Windows.

docker run -d -p 8123:8123 --privileged --volume "$HOME/Users/bruce/Documents/homeassist:/config" --name homeassistant -e "TZ=America/Los_Angeles" ghcr.io/home-assistant/home-assistant:stable`