Docker container does not get assigned a port

I am trying to install HomeAssistant on TrueNAS via an Ubuntu VM I have installed on there, and no matter what I do it does not expose port 8123 to the application on container creation.

To start, if there’s an easier way to do this on TrueNAS core I’m all ears.

The command I’m running, as sudo:

docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=America/Phoenix
  -v /PATH_TO_YOUR_CONFIG:/homeassistant
  --network=host \
    ghcr.io/home-assistant/home-assistant:stable

I’m taking it straight from the HomeAssistant Container Install page and modifying it slightly to reflect my timezone and where I want it installed.

I understand that by default, the host network in docker does not expose ports to the application, so I’m wondering if I need to create a user defined network that does?

Update, tried installing the Raspbian image directly in TrueNAS via the virtual machine console, and the VM immediately fails on startup.

I’m all ears for ideas. I’d love nothing more than to get IFTTT out of my life.

Yourb

The “–network=host” means all ports are exposed and accessible

Do you have other containers or services using port 8123? I dont use trunas but possibly there is firewall rule blocking docker or HA.

Also, you do “docker run” but did it actually run or did it stop? How you verify container start before try 8123 and trying to login HA?

If you replace the “-d” with “-it” it will run in interactive mode and you can see what is going on. To get out of interactive mode, press ctrl-P then ctrl-Q.

Output of sudo docker ps

I checked, nothing is using port 8123 according to lsof within the VM.

Let’s back up a step. Is this the best way to install it on TrueNAS or is there a disk image I can use to install it directly?

this should be

-v /PATH_TO_YOUR_CONFIG:/config

as the doc states…
EDIT: you of course have to provide the actual value for ‘PATH_TO_YOUR_CONFIG’

That’s probably the piece I’m missing to make it work. Can you give me an example of what that would look like in the real world?

you need to provide a local folder to map to the folder within the docker container, i.e. ‘config’
You would normally (my way at least) create a base-folder called ‘docker’ somewhere on you machine
say /home/[yourname]/docker
Within that you create a folder homeassistant
and then you use this

-v /home/[yourname]/docker/homeassistant:/config

of course it does not have to be in home but this is what I like…

EDIT the docker folder you will then use later for other containers as well
EDIT2: make sure you have space on your disk where ‘docker’ resides as this will grown when you add more and more… a full disk will crash the lot.

Just as a general list of things I’ve tried so far:

  • The docker install, it hurt my brain and when I realized I was going to have to do manual configuration, I said “Look there’s some shiny disk images. Let’s try loading those as VMs.”
  • Funny joke, I said a half hour later as every attempt to load the x86 image results in the UEFI not being able to find the .efi file. This is what i’ve been troubleshooting for an hour.

I think I’m going to toss in the towel on this for the night, and I’ll look at this with fresh eyes tomorrow.

The VM one with HAOS uses add-ons which in fact are containers too but there you have ‘supervisor’ to deal with that. It will work very fine for almost all installs. I chose docker as I want to run non-HA stuff on the same machine.
good luck

i think this is an ubuntu firewalll rule.
not easy to find.i remember if you use ufw it close port and even if you make rules.
i remember to have to check iptable under ubuntu with ufw

Yep…that is a 2nd thing to check…but the docker config was not good by itself too…

For me the following worked:

using docker compose —> “expose”: https://www.baeldung.com/ops/docker-compose-expose-vs-ports

docker-compose.yml

version: '3'
services:
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - /home/pi/docker/homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    privileged: true
    network_mode: host
    
    expose:
      - "8123"

run with

cd /home/pi/docker/homeassistant
sudo docker compose up

now i can access: http://192.168.0.9:8123/onboarding.html