Docker container running but cannot open HA

Hi,
I have just upgraded to NUC and trying to setup HA docker. Everything works fine until the NUC restarts, the moment it is up, access to the web interface of HA is gone although I can see the container is running and up-to-date.
I have tried restarting container multiple times but nothing helps.

Here is the docker-compose file which I am using

version: '3.7'
services:
  portainer:
    container_name: portainer
    restart: unless-stopped
    image: portainer/portainer
    volumes:
      - /home/piyush/HomeAutomation/portainer_data:/data
      - /var/run/docker.sock:/var/run/docker.sock
    network_mode: host
  homeassistant:
    container_name: home-assistant
    restart: unless-stopped
    image: homeassistant/home-assistant
    volumes:
      - /home/piyush/HomeAutomation/hass-config:/config
      - /etc/localtime:/etc/localtime:ro
    network_mode: host
    privileged: true

Please note that portainer works absolutely fine even after the host system restarts or recovers from a power failure.

Has anyone seen this before, any inputs would be highly appreciated.

Look at the logs and see what it says about HA not running. I’m guessing you have an error in your config or your db is corrupt

Why did I not think of that (am so dumb, lol). Here is the error that I see in the logs

ERROR (MainThread) [homeassistant.bootstrap] Error loading /config/configuration.yaml: Config file not found: /config/lights.yaml

Obviously, it is not able to find the !include files which I have used in the configuration.yaml file. The reason I feel is that the path /config/configuration.yaml does not exist, not sure why the /config is getting appended before the name. All the files are present in the root folder /hass-config

Because INSIDE the container the path is /config. You told it as such in the docker compose file.

Thanks for the input, I went back and looked at the files and indeed this one was missing. Everything was fine after I created this file again. Thanks for realizing me the silly mistake I was doing :grin:.

On a side note, how do you update your configurations? because the moment I add one of the folders as a volume, that folder is now owned by root user and I cannot make any changes and for every modifications I have to do sudo.
Adding to this, we cannot copy, paste or create new files as well from GUI because of these restrictions.
So, I want to understand you workflow as to what is the best approach here.

I personally store all my config under /home/homeassistant and then point HA to that folder.

Any changes can be made via SSH, and then restart the container using Portainer. I don’t install via docker-compose, I just manually run the docker install, then this use this config.

sudo nano -w /etc/systemd/system/[email protected]

…paste in

[Unit]
Description=Home Assistant
Requires=docker.service
After=docker.service

[Service]
Restart=always
RestartSec=3
ExecStart=/usr/bin/docker run --name="home-assistant-0.86.4" -v /home/%i:/config -v /etc/localtime:/etc/localtime:ro --net=host homeassistant/home-assistant:0.86.4
ExecStop=/usr/bin/docker stop -t 2 home-assistant-%i
ExecStopPost=/usr/bin/docker rm -f home-assistant-%i

[Install]
WantedBy=multi-user.target

then…

sudo systemctl --system daemon-reload
sudo systemctl start home-assistant@homeassistant

I manage the containers from Portainer after install. It’s probably not the prettiest way to do it, but it works for me. :slight_smile:

I use syncthing. I do it locally on my desktop or laptop. Syncthing syncs it back in real time to my ha host

1 Like

I’m pretty confident in saying that you don’t need to do anything with the services that you are doing.

All of of that is needed for running as a service in a virtual environment that isn’t need to run in a docker container. All you need to do is run your docker run command and make sure the container is running.

1 Like

Yeah, you’re most likely correct.

I just keep doing it as a fallback as it’s how I have always done it going back to the oldskool script that was available to install HA in a venv using a Pi and Raspbian, back around 0.45.0 or something when I first got on board with HA.

Old habits :wink: