In this piece we’ll be installing Home Assistant in Docker on Cent OS. The reasons why I chose Cent OS and how to set it up are described in the following posts:
- Set up a secure home server with Cent OS – Part 1
- Set up a secure home server with Cent OS – Part 2: Samba
Because of scalability and administratability, I’ve decided go to with Docker containers this time. My Pi already runs Hass.io and I like the ability to enhance Home Assistant by simply adding add-ons, which are essentially other Docker containers. That’s why, in this write-up, I’ll be using the Hass.io install for non-pi systems.
First of, we need to install a few software packages as prerequisites, but these are not in Cent OS’s default repos, so we need to integrate the Extra Packages for Enterprise Linux 7 repo maintained be Fedora. For Ubuntu or Debian users, this is not a relevant step.
sudo yum -y install epel-release
Update and check:
Now, we can install the prerequisites:
Of this list, we still need to add jq, socat and avahi-daemon (which is basically bonjour or mDNS):
yum install jq socat
Ubuntu or Debian users should replace yum with sudo apt-get.
Installing Hass.io containers
Because the code on the Github page of Hass.io wants to create a directory where it does not have the permissions to, we need to set up the directory in advance ourselves.
sudo mkdir /usr/share/hassio
Then we want to run the code in superuser mode, otherwise the script won’t work due to a lack of administration rights. Before running this code, review the script that you’re about to kick off. Running scripts through bash is a serious security risk and should always be proceeded with caution!
sudo -s curl -sL https://raw.githubusercontent.com/home-assistant/hassio-build/master/install/hassio_install | bash -s exit
Allow access through the firewall
Let’s add the home-assistant port to our firewall (not relevant on default Ubuntu or Debian).
sudo firewall-cmd --permanent --zone=public --add-port=8123/tcp
sudo firewall-cmd --reload
Mapping SAMBA share
Then we want to map the new Hass.io folder to SAMBA so we can remotely access it and upload our config. In the previous tutorial, you can read how to set up SAMBA on Cent OS. Here however, we’re going to edit the SAMBA file we currently have.
sudo vi /etc/samba/smb.conf
Most important is the hassio path (in its separate section).
# See smb.conf.example for a more detailed config file or # read the smb.conf manpage. # Run 'testparm' to verify the config is correct after # you modified it. [global] netbios name = XR-APP01 server string = XR-APP01 workgroup = WORKGROUP hosts allow = remote announce = remote browse sync = security = user map to guest = bad user dns proxy = no passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw #===================== SHARES ====================== [Docker] path = /opt/Docker browsable = yes read only = no valid users = @linux writable = yes guest ok = no [Hassio] path = /usr/share/hassio browsable = yes read only = no valid users = @linux writable = yes create mask = 0777 directory mask = 0777 force user = root force create mode = 0777 force directory mode = 0777 [homes] comment = Home Directories valid users = %S, %D%w%S browseable = No read only = No inherit acls = Yes [printers] comment = All Printers path = /var/tmp printable = Yes create mask = 0600 browseable = No [print$] comment = Printer Drivers path = /var/lib/samba/drivers write list = root create mask = 0664
In this case I’ve forced a privileges mask in this directory when using SAMBA, otherwise the files cannot be edited because of the lack of privileges. This does not apply when accessing the directory over for example SSH.
Hass.io is now set up with two Docker containers. One is the hypervisor the manage the Home Assistant container and any additional add-on containers. The other, obviously, is then the Home Assistant container itself. If you need to reset Home Assistant, it’s no longer necessary to restart the whole server. All that is needed is restarting the particular Docker container:
docker restart homeassistant
Otherwise, find the container id:
This should give you something like this:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 344d37021ecf hassioaddons/homebridge-amd64 "/init" 16 hours ago Up 16 hours addon_a0d7b954_homebridge 035e35e922d7 homeassistant/qemux86-64-homeassistant "/usr/bin/entry.sh p…" 16 hours ago Up 12 hours homeassistant f5bff8363e3d homeassistant/amd64-hassio-supervisor "/usr/bin/entry.sh p…" 2 days ago Up 16 hours hassio_supervisor
Then use the first few characters of that container:
docker restart 035e5
To see the status, query Docker:
To conclude this short article: yes, it works and everything is set up automagically including add-on Hass.io containers. However, I dislike the lack of control and documentation on this. I’ve my other containers managed through docker-compose and I would’ve liked to do the same with Home Assistant. In a future post I’ll write on how to convert this current set up of Home Assistant to docker-compose, because it then also allows for distributed functionality which in turn should help in the case of outages.
Perhaps you and I can try to help the project by further improving it’s documentation and make posts like this unnecessary in the future. =)