Install other software in the HA container

This question is almost certainly a docker question and not a Home Assistant question, but maybe not.

First of all, I am a docker newbie. I followed the instructions to get supervised HA running on a Debian laptop. I also have portainer running. I have seen that I can open a shell window in the homeassistant container from within portainer, and that gets me access to my config files, etc. I also have samba and ssh running, so I can get to things that way (usually from my windows pc). In fact, that’s how I do most of my editing. Everything works.

But let’s say I am on my laptop and I want to edit a file. I could go into portainer, but I don’t see any editors like pico, nano or vim. And I don’t see a way to apt-get install things either. But when I go to my desktop, I have pico, nano and vim installed. But there’s no easy way that I can see to access the container files from my debian desktop.

So, how do I install other things in the docker container? Or is that a bad idea and there’s a better way to do things?

What particular instructions did you follow?

Your data files should be located in the guest OS outside of the container. Otherwise you would lose your data every time you upgrade HA by replacing the container with a newer version.

Uh oh, that sounds bad! I did it a couple of weeks ago and I don’t know exactly which site I followed (there are so many of them). Fortunately I have been backing everything up every day.

I’ll look at the home assistant site and make sure I am doing it right.

The official instructions are here.

Oh wow! I figured it out. I went into portainer and looked at the info for the HA container. I found this:

        "Destination": "/config",
        "Mode": "rw",
        "Propagation": "rprivate",
        "RW": true,
        "Source": "/usr/share/hassio/homeassistant",
        "Type": "bind"

So I went to /usr/share/hassio/homeassistant and all of my config files are already there. Even stuff I edited today. So I don’t have to “go into” the container to see my files! And I created a new file in /usr/share/hassio/homeassistant and sure enough, it showed up in the container as well, so it seems to replicate both ways. So, in the future, I’ll just edit the files in /usr/share…

Am I understanding correctly?

Sounds like it.

And to be clear.

there is almost never any reason to ever install anything inside the HA container…or any other container.

it’s almost never required and as mentioned the changes will be wiped out as soon as you rebuild/update the container

2 Likes

Check out the file editor add-on, or add samba access add-on and use visual code from your PC to edit yaml

For editing, there is also hass-configurator. This lets you edit within the HA browser window.

I use samba and ssh. But sometimes I take my HA laptop to the place where I am working (garage perhaps). Then I want to edit on the laptop itself. But yeah, normally I do all of my editing on my windows PC. I’ll take a look at that hass-configurator too. That looks nice.

I just use it to edit & save the files. I check & restart HA from the Configuration menu. You need to set the HASS_SPI to a blank string if you do this. Here is my (redacted) settings.conf

{
  "BASEPATH": "/hass-config",
  "HASS_API": "",
  "ALLOWED_NETWORKS": [
    "redacted/24"
  ]
}

@Prodigyplace , can you help me a bit more? I want to install the hass-configurator, and I have some questions.

I think I will install this:
https://hub.docker.com/r/causticlab/hass-configurator-docker/

From the instructions:

Usage

Example docker-compose.yaml

  hass-configurator:
    image: "causticlab/hass-configurator-docker:latest"
    restart: always
    ports:
      - "3218:3218/tcp"
    networks:
      - hass-network
    volumes:
      - "./data/configurator-config:/config"
      - "./data/config:/hass-config"

Configuration

Be sure to map the config folder of your homeassistant instance to the configurator container and set the basepath in your configuration. The configuration needs to be mapped to /config and needs to be named settings.conf.

  1. What do they mean by “map the config folder”? I have a feeling it has something to do with the volumes setting in the docker-container.yaml file. I read most of this page: Use volumes | Docker Documentation but I am having a hard time understanding all of it.
  2. The redacted snippet you posted mentions the basepath setting, but I don’t see where that setting needs to go. It doesn’t match up with the suggested docker-compose.yaml file, so I am guessing it will go somewhere else. Where does that snippet go?
  3. Finally, the networks setting in the docker-compose.yaml. My network is 192.168.0.*. Is “hass-network” meant to be entered there verbose, or should I put something like “192.168.0.0/24”? I don’t see any environment variables named “hass-network” in the container or on the host.

For my installation, the host sees the HA config files in /usr/share/hassio/homeassistant. My configuration.yaml is in that directory. From within the container, my configuration.yaml is in /config as expected.

Again super sorry for all the newb questions, but I really appreciate your help!

I use a shell script to run my docker container. I chose to make a folder for it in my homeassistant data folder.

That is the folder that contains the hass-configurator config file settings.conf.

In the settings.conf file in the config folder.

So, to be similar to what I did, make a configurator folder in /usr/share/hassio/homeassistant and make a settings.conf file in that folder. Here is a modified example of my startup script. It first checks for a newer image & then runs the container.

docker pull causticlab/hass-configurator-docker:latest

docker run \
  --init \
  -d \
  --name hass-configurator \
  --privileged \
  --restart=unless-stopped \
  -v /usr/share/hassio/homeassistant/configurator:/config \
  -v //usr/share/hassio/homeassistantt:/hass-config \
  --network=host \
  causticlab/hass-configurator-docker:latest

No worries at all.

Here’s wishing for a fruitful 2022!