Confusion around HA, Docker, Portainer and ports

I have been running Home Assistant (as Hassio) on a raspberry pi for quite a while. I recently decided to move to a NUC and installed Ubuntu, then Docker, then Portainer, then Home Assistant. I essentially followed this guide: https://medium.com/@jordanrounds/intel-nuc-home-assistant-supervised-7cc52d81744a

Everything is working well with Home Assistant. My raspberry pi is still running as my front end web server and proxying information to my Ubuntu NUC. I want to change that and I have installed an Apache Docker Container, configured it for SSL, etc. So now I’m ready to implement my proxy steps in Apache on the NUC and I’m a bit confused.

For the Docker container that I’ve created, I see ports listed in Portainer (443, 80, etc). For the Home Assistant one, I do not see 8123 listed as a Published Port. Why not? Did I do something wrong in my setup?

What I was anticipating doing was changing my HA server_port to something else (8124), then setting up the Apache proxy to take https://public_ip:8123 and pushing it to http://internal_ip:8124. I tried to change my config to server_port: 8124, then restart HA and I couldn’t access it (I assume because docker didn’t know to expose this port).

I can change my apps to look at https://external_ip:8124 and then proxy that back to 8123, I guess it’s basically the same, but I was curious why I couldn’t just change server_port: in my config. I’m new to Docker, so I’m sure it’s something that I’m doing wrong… Thanks!

I might not explain this very well, but homeassistant runs in ‘host’ network mode, so it basically has all the ports. Then when you have other containers where you do specify ports, docker sends those ports to those containers and the remaining ones to homeassistant (or any others using host mode).

Ah ok. So I see that in Portainer on the container itself, it has a network section that says Host for the Homeassistant one and Bridged for my Apache Docker container.

But then, if I change my server_port: in my home assistant configuration.yaml, why wouldn’t it be accessible directly on the rest of my network? I think I may have answered my own question by typing that, I bet I have a ufw rule in Ubuntu… I’ll change my server port and check my firewall.

Yeah, that was my issue. Forgot I had enabled ufw! Changing the server_port: directive and running ufw allow 8124 enabled me to now load HA on another port through Docker.

1 Like