Help with Docker ports?

Hi All,

I’ve spent 24 hours going through all of the possible ways to install HA on my Mac server, and followed a million online tutorials, but nothing seems to get me up and running completely!
I’ve settled on Docker - as this seems to get me closest to a running HA installation - I can get to the web portal and it can see my Tradfri and Hue devices all OK. YAY!!

I’m having issues with the Homekit integration though, and it seems that the problem I’m coming across might be tied to Mdns & Port forwarding to the docker container (although I’m not certain).

I think I’ve managed to forward 8123 and 51827 to the docker, - at least they are showing as forwarding in Portainer. However - I can’t get it to show up in the home app.
As a side note, HA doesn’t appear to be able to see my LIFX lights either, which seems to point to it being a port forwarding issue.

I’m a complete noob with Docker, and this is the first time I’ve done anything with it.
Can someone tell me how I might either expose all ports to the docker container, or a subset so that it might work?

Or - give me some troubleshooting to see if we can work out how to get it going!!

Thanks in advance

add this to your docker run command:

--net=host

it exposes all ports on the host to the container.

Yep --net=host is the only solution for multicasts on docker. Multicasts are essentially broadcasts and can’t be forwarded to another subnet. You have to use the real host address which is what net=host does.

Note you also may not be able to use those technologies in other programs or OS at the same time, only one process can lock a particular port. So don’t be surprised if you have to disable a process on your OS for it to discover in Hass. OS’s typically have a listener process that other process using mutlicast register with, but Hass running in a container isn’t going to participate in that. If you have issues wiith discovery type stuff even with net=host you may be better off with a native install or a VM with it’s own IP.

Thankyou!
I’ve tried to give this a go (again, apologies for the lack of knowledge around Docker)
What command do I type to get it to add the net=host?

When I try to start it, I get the below errors. I tried to re-create it in Portainer, but then I don’t know how to add the --net=host argument to it.

I’ll give this one last go if you can help me with that, but I did also try to run it within a VM in Virtualbox. I found a list of specs in a YouTube video and followed those to get it to run, however it also failed to start, erroring out with a clock/frame not responding or something like that.

I tried to look for a list of specs to configure the VM environment as well but couldn’t find any solid documentation on the site as to what HA expects it’s environment to be?


docker start --net=host hass

unknown flag: --net

See ‘docker start --help’.

Wildthing-Server:~ benwilding$ docker run --net=host hass

Unable to find image ‘hass:latest’ locally

docker: Error response from daemon: pull access denied for hass, repository does not exist or may require ‘docker login’: denied: requested access to the resource is denied.

See ‘docker run --help’.

Wildthing-Server:~ benwilding$ docker start hass --net=host

unknown flag: --net

to add that flag, you have to delete the current running container, and re-run your run command, replacing the -p 8123:8123 (and any other -p you added) with the --net=host

Thanks - gave this a go, now have docker showing as running within Portainer, however I can’t access the homepage.

I assume this is because of the conflict Wuench mentioned above “If you have issues wiith discovery type stuff even with net=host you may be better off with a native install or a VM with it’s own IP.”

So, I think I’m going to try to have it run in it’s own VM. Can anyone shed some light as to what the configuration needs to be for Virtualbox?

What is running that’s using port 8123?? It was working earlier correct? What changed? If there was something on the host listening on port 8123 then you wouldn’t have been able to map that port anyway.

You don’t need to…

So, I now have everything running smoothly in a VirtualBox VM.
It’s not the elegant solution I wanted, but hey - at least it works & it’s a controlled environment I suppose.

Just so you know - I don’t think there’s anything else running on that port. However, I am running other services (Plex server, Davinci Resolve project server etc) on that machine, so (and this is just a guess) as wuench mentioned above perhaps you can’t use multicast on both a host OS and a docker container?

No. You’re misunderstanding his point.

You simply can’t have multiple services all listening on the same port. This has nothing to do with multicast.

Ah. OK.
In that case, I’m really not sure then.
I reinstalled the docker container and pointed it to the existing config file, as I originally set it up.
I replaced the -p and the ports with --net=host, and it created a new docker which appeared to fire up OK.

Portainer listed the docker as running, but didn’t list any specific ports as being redirected (I suppose that would be right if you’re joining to to the host network ?)

But it just didn’t respond when I tried to get to the web page.

Correct.

So what did your log files say?

Ahh never mind buddy (thanks for your help). I think I’m happy just running it in the VM now - I’ve been playing with it and have it all configured and working OK, so I think I’ll just go with this.

I suppose it’s also better documented and a known system - unless there’s a good reason to continue down the docker route?

Docker is by far the best way to run home assistant IMHO.

Instructions are here https://www.home-assistant.io/docs/installation/docker/ - it is unclear whether you were following them.

I have followed those instructions and I am having the same problems. Problem is when --net=host is used, docker container starts but it is not accessible in the browser. Browser says page not found. I am able to access it via browser if I use port instead of --network=host

3 years later? Oh well, tell us your docker command in full.