How to install Home Assistant within an LXC container

I have published this blog post to help anyone having issues installing Home Assistant (and Docker) in an LXC container running on Ubuntu.

When I was installing Home Assistant on my own hardware, I could not find any straight-forward guides detailing how to do this, and Home Assistant’s own documentation does not help with installing in an LXC container.


Step 1 – Create your LXC container

If you have not already done so, create a LXC container in the same way you normally do, if you already have done this, skip to Step 2.

In this example my container storage is run on ZFS. You must ensure you have at least 36GB of storage space available.

Following these instructions, replace lxd-homeassistant with your own container name if you wish.

Create a new container:

sudo lxc launch ubuntu:18.04 lxd-homeassistant

You can set CPU and Memory limits using the following commands:

For CPU:

sudo lxc config set lxd-homeassistant limits.cpu 1

For Memory:

sudo lxc config set lxd-homeassistant limits.memory 1024MB

You can also set Hard Drive size limits with ZFS. To limit the hard drive space of a container.

Note: ‘zfs’ is the ZFS name and ‘zpool’ and ‘containers’ are the pool names, the path can be found
using: sudo zfs list

sudo zfs set quota=36G zfs/zpool/containers/lxd-homeassistant


Step 2 – Give your container specific privileges

Setup container privileges:

sudo lxc config set lxd-homeassistant security.nesting true
sudo lxc config set lxd-homeassistant security.privileged true

Now run each of these lines separately:

cat <<EOT | sudo -
lxc config set lxd-homeassistant raw.lxc
lxc.cgroup.devices.allow = a
lxc.cap.drop =

Now restart the container:

sudo lxc restart lxd-homeassistant


Step 3 – Install required packages for Home Assistant

Update your packages:

sudo apt-get update

Install required packages:

sudo apt-get install bash jq curl avahi-daemon dbus software-properties-common apparmor-utils libnss-mdns mdns-scan


Step 4 – Update and reboot the LXC container

There is a known issue which can affect install Home Assistant. An upgrade and reboot should fix the issue:

sudo apt update && sudo apt dist-upgrade


Step 5 – Run the Home Assistant script

Run the install script:

curl -sL "" | sudo bash -s -- -m qemux86-64

The installation will take up to 20 minutes depending on how fast your Internet connection is.

Once Home Assistant is installed, you can access the setup via: http://YOUR-LXC-CONTAINER-IP:8123/ – Replace YOUR-LXC-CONTAINER-IP with your own LXC container’s IP Address.

There are no comments, be the first. Use the form below to add your comment

Post a Comment