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.

NOTE: As of 18/06/2020 This install method now uses the ‘Supervised installer‘. Discussion regarding deprecation on this method is continuing on GitHub and Home Assistant’s website.


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

Within your container, run these commands:

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

Still within the container, follow the step below:

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

Still within the container:

Run the install script: (This is the updated method using a ‘Supervised’ install as of 18/06/2020)

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

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

Alternatively, the old method may still work, or may not:

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

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.


  • June 7th, 2020

Hi Ryan,
thank your for putting these steps together!

Steps 3-5 need to be executed in the container itself, right?


  • June 7th, 2020

Hi Andreas, Yes that’s correct. Steps 3-5 are to be run in the container.


  • June 18th, 2020

I am getting a 404 error when trying to run the curl command to install the script. Did they remove the script from Github?

  • June 18th, 2020

Hi David, yes they have moved this method to a new repo, known as the supervised install:

FYI Discussion regarding deprecation on this method is continuing on GitHub and Home Assistant’s website.

For now, I am still using this method, everything seems to be working. There was a lot of backlash regarding their deprecation announcement which they announced on 10th May 2020, this forced them to put the deprecation on hold as of 24th May 2020.

  • November 18th, 2020

“You must ensure you have at least 36GB”

  • November 18th, 2020

This is a requirement by the developers of Home Assistant:, I added a few gigabytes extra as storage for the container.

Lars Nørgaard
  • January 21st, 2021

Where do you set the ZFS storage pool that will be used?

  • January 21st, 2021

Hi Lars, this would be done when you install and setup the base LXD configuration with ‘lxd init’.

This page covers how to install LXD and setup the storage pool to be used:

  • April 9th, 2021

The install script seems to break the container network, so no IP

[warn] Changes are needed to the /etc/network/interfaces file

and then:
Error response from daemon: Get net/http: TLS handshake timeout

  • April 9th, 2021

I’ve not experienced this myself. Can you confirm if you can ping a website in the container before starting to install Home Assistant

  • April 11th, 2021

Hi, I have a problem with additional setup lxc especially with the command of EOT. I’ve got sudo: -: command not found

  • April 15th, 2021

Hello, it may be a copy and paste issue from my notes.

Try typing in a hyphen from your keyboard instead of copy and pasting it. I sometimes have these issues too.

  • April 11th, 2021

@Thomas I have exactly the same problem. Because I am using mcvlan for my containers and the problem becomes when I install the network-manager, then my container lost the eth0 address and container has no internet. I have no idea how to solve it..

Ryan McKenzie
  • August 14th, 2021

Couldn’t get past :
cat <<EOT | sudo –
lxc config set lxd-homeassistant raw.lxc
lxc.cgroup.devices.allow = a
lxc.cap.drop =

I tried typing everything like Ryan told petr, but I still get :
sudo: -: command not found

Also tried it as root (sudo su) as a hail mary, but it didn't help. I suppose its not a huge problem. I'll just leave it running in KVM. It's my last holdover in the KVM world, would have been nice to have it all in one place. But once installed how often do you ssh in or touch the underlying os. I'll take simple at the cost of some RAM and Storage.

Post a Comment