Home Assistant and Docker

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp

Home Assistant and Docker




Nowadays smart homes are becoming pretty common and having multiple devices from different manufacturers are becoming a millenial problem where we dont want to have multiple apps in order to check routines or whats off, of course this helps in saving electricity but is not an easy task but with Home Assistant and Docker that can change.

There are other alternatives to this set up such as Alexa or Google Assistant but Home Assistant is a really good alternative if you want to keep your privacy locally and not shared with those two internet monsters.

Home Assistant is open-source, self-hosted software that will allow you to control various devices in your home.

Docker has become one of the easiest ways to set up virtual enviorements for apps on Linux, Mac and even Windows Machines.

Be sure to run sudo apt-get update and sudo apt-get upgrade.

Install Docker

Run the following command:

curl -sSL https://get.docker.com | sh


You are going to want to add the proper permissions to your primary user account to easily run docker commands. To do that, run the following command:

sudo usermod -aG docker YOURUSER

Replace YOURUSER with the name of the user you are logged in as.

Since we made some changes to our user, we will now need to log out and log back in for it to take effect.

You can log out by running the following command in the terminal.


Once you have logged back in, you can verify that the docker group has been successfully added to your user by running the following command.


This command will list out all the groups that the current user is a part of. If everything worked as it should, the group docker should be listed here.


Docker should be running by this point. Running the following command should pull an image from the Docker Hub and display hello-world on your screen.

docker run hello-world

Troubleshooting Docker Installation

If you get the following error:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.


sudo dockerd

If dockerd shows the following error:

failed to start daemon: Error initializing network controller: list bridge addresses failed: PredefinedLocalScopeDefaultNetworks List:

Then run the following two commands:

sudo ip link add name docker0 type bridge
sudo ip addr add dev docker0

Activate the service:

sudo systemctl enable docker
sudo systemctl start docker

Test Docker:

docker run hello-world

If you get the following error:

Unable to find image 'hello-world:latest' locally

Then type:

docker login

You have to have an account with docker if you dont have it then sign up for one.

and then test again:

docker run hello-world

Install Dependencies (Docker Compose)

To keep everything running smoothly, you’ll want to run the following commands to install the following dependencies:

sudo apt-get install -y libffi-dev libssl-dev
sudo apt-get install -y python3 python3-pip
sudo apt-get remove python-configparser

Install Docker Compose (Optional)

For more advanced scenarios, you can install Docker Compose to allow you multiple containers that are dependent on each other with a single command:1

sudo pip3 -v install docker-compose

Create a Volume for Home Assistant

In order to store persistent data, we have to first create a volume in Docker. This is where Home Assistant will store configuration data. Make sure you store it in a location that you can easily access the files. In order to properly work with Home Assistant, you will be consistently editing various configuration .yaml.

docker volume create home_assistant

Home Assistant Install

Below is the docker run command. After creating the home_assistant volume, you can copy and paste this command into your terminal in order to download and run the Home Assistant image from the Docker hub. Make sure you change the environment variable -e TZ=America/New_York to your time zone. You can locate your TZ database name here.

Also, it is required to use the docker host network (--net=host) for the Home Assistant container image.

docker run --init -d \
--name="home-assistant" \
-e TZ=America/New_York \
-v home_assistant:/config \
--net=host \


Below is the list of variables in the above run code.

--name="home-assistant"The name of your docker container
-e TZ=America/New_YorkYour time zone from the TZ Database
-v home_assistant:/configPersistent storage location for the /config folder within the container
--net=hostPlaces the container on the host network


After you run the above Docker run command, you will be able to access your installation at http://YOURIPADDRESS:8123. Now you will be prompted to set up your user account and can begin adding your devices.

Now you have installed Home assistant and Docker.

Remove Docker from System.

To completely uninstall Docker:

Step 1

dpkg -l | grep -i docker

To identify what installed package you have:

Step 2

sudo apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce

The above commands will not remove images, containers, volumes, or user created configuration files on your host. If you wish to delete all images, containers, and volumes run the following commands:

sudo rm -rf /var/lib/docker /etc/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock

Share Post

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp

Related Posts


Google Sheets and Python

Nowadays Google Docs has been integrating a whole bunch of features with its amazing API that you can use from triggering a Python script hosted

Read More »